rightcapitalhq/frontend-libraries/assert
Claude Code and agent skill by rightcapitalhq/frontend-libraries
- community
Checking that the SKILL.md file is still in the repository.
Type-safe assertion and validation utilities for defensive TypeScript programming. Use when writing runtime assertions, null checks, type guard validations, unreachable code markers, exhaustive switch/if-else checking, or unimplemented stubs. Import named functions from @rightcapital/assert.
Install
npx vskill@latest install rightcapitalhq/frontend-libraries/assertSKILL.md
assert
Type-safe assertion utilities for defensive TypeScript programming. All functions throw AssertionError (which extends Error) on failure. Error messages are formatted as ${functionName}: ${message}. When no message is provided, value assertions default to Unexpected ${String(value)}.
Import
Quick Reference
| API / Signature | Description / Typical Use Case | |
|---|---|---|
AssertionError extends Error | Error type thrown when any assertion in this package fails. | |
assert(value: boolean, message?: string): asserts value | Precondition or boolean check (verifies value === true). | |
assertNonNullable<T>(value: T, message?: string): asserts value is NonNullable<T> | Guard statement against null or undefined. | |
ensure<T, S extends T>(value: T, predicate: (value: T) => value is S, message?: string): S | Inline validation using type guard function (val: T) => val is S. | |
ensureNonNullable<T>(value: T, message?: string): NonNullable<T> | Inline assignment or method chain for non-null value. | |
assertExhaustive(value: never, message?: string): never | Exhaustiveness check in switch default case or if-else chain. | |
assertUnreachable(message?: string): never | Mark logically impossible code paths. | |
unimplemented(message?: string): never | Mark a stub that always throws AssertionError. |
Error Handling with AssertionError
All assertion functions throw AssertionError when a condition is not met. Use instanceof AssertionError to catch assertion failures specifically:
Critical Rules for Code Generation
1. assert() Checks Strict Boolean Equality (value !== true)
assert(value) throws if value !== true. It throws for truthy non-boolean values like objects or strings.
- Incorrect:
assert(user);(throws even ifuseris an object) - Correct:
assertNonNullable(user); - Correct:
assert(user.age >= 18, 'Must be 18+');
2. Choose assert* Statements vs ensure* Expressions
- `assert*` functions are statements. They narrow the type of an existing variable for subsequent code.
- `ensure*` functions are expressions. They return the validated value with a narrowed type for direct assignment or chaining.
3. ensure() Requires a Type Guard Predicate
The predicate parameter in ensure(val, predicate) must be a TypeScript type guard ((val: T) => val is S). A standard boolean function without a type predicate will cause a compile error.
4. assertExhaustive vs assertUnreachable
- Use
assertExhaustive(value)when TypeScript can prove all union cases are handled (e.g.,switchdefault case). It catches missing union members at compile time becausevaluemust be typed asnever. - Use
assertUnreachable(message)for defensive checks in branches that TypeScript cannot prove unreachable. - Prefix with
returnin non-void functions (for example,return assertExhaustive(val);orreturn assertUnreachable(msg);) to satisfy ESLintconsistent-return.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingpackages/assert/skills/assert/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/rightcapitalhq/frontend-libraries/assert)