Type Narrowing
CheckedType Narrowing refines search queries by suggesting more specific types of content, boosting relevance and saving you time finding exactly what you need.
Install on your platform
Showing Claude Code. One command installs this skill into any of the agents below.
- 1
Run this in your project
terminal$ npx skills add marius-townhouse/effective-typescript-skills --skill type-narrowing -a claude-code Uses the open-source
skillsCLI and needs Node.js. Add-gto install it for your user instead of this project.
What we know about this skill
Publisher
marius-townhouse
Taken from the source listing. We haven't verified who controls this account.
Install target
Live repository
Not pinned. Installing fetches whatever the repository holds at the time you run the command.
Automated safety checks
This skill passed all 6 checks. We read its files at one commit and looked for the things that make a skill dangerous to run — not for whether it works.
Declares what it does: passed
SKILL.md parses and declares a name and a description.
SKILL.md exists, its frontmatter parses, and it declares a name and a description.
No undeclared network calls: passed
Makes no network calls.
Every host the skill dials — from its scripts, its config endpoints or the commands it tells the agent to run — is either well-known package and API infrastructure or declared in its own frontmatter. Links in documentation are not counted.
No obfuscated payloads: passed
No encoded or obfuscated payloads.
No base64, hex or compressed blob is decoded and then executed, and no encoded shell commands.
No credential access: passed
Reads no keys, tokens, keychains or credential files.
Neither the code nor the SKILL.md instructions read SSH keys, cloud credentials, keychains, token stores, browser cookie databases or dotfiles that hold secrets.
No pipe-to-shell installers: passed
No pipe-to-shell or download-and-run installers.
No `curl … | sh` pattern, in the code or in the instructions, that runs code fetched at run time.
Pinned to a commit: passed
Scanned marius-townhouse/effective-typescript-skills at d754db2077.
The exact upstream commit SHA that was scanned is recorded, so the result refers to specific bytes.
- Commit
- d754db2077
- Manifest
- skills/type-narrowing/SKILL.md
- Scanned
- 1 file, 273 lines
About this skill
What it does
The type-narrowing skill allows an AI agent to refine the type of a variable within TypeScript code. This process involves using techniques like conditional checks, discriminated unions, and type predicates to ensure that variables are treated as more specific types than initially declared. The goal is to improve code safety and enable more precise operations on data.
When to use it
- Handling union types: When a variable can be one of several types (a union), this skill helps determine the exact type at runtime for targeted processing.
- Working with discriminated unions: To safely access properties unique to specific members within a discriminated union.
- Refining
anytypes: To gradually eliminateanyand improve type safety in legacy codebases. - Implementing complex conditional logic: When TypeScript's type system needs assistance to correctly infer the type of a variable based on runtime conditions.
Key capabilities
- Conditional Type Narrowing
- Discriminated Union Handling
- Type Predicates
- Runtime Type Checks
Example prompts
- "How can I narrow the type of
datawhich is declared asstring | numberto anumberif it's greater than 10?" - "I have a discriminated union with a 'kind' property. How do I access properties specific to each kind safely?"
- “Explain how to use a type predicate in TypeScript.”
Tips & gotchas
This skill requires a basic understanding of TypeScript’s type system and the concepts of unions, intersections, and generics. Incorrect usage can lead to runtime errors if the narrowing logic is flawed.