@rightcapital/assertion-helpers
v2.1.2
Published
Type-safe assertion utilities for defensive programming.
Readme
@rightcapital/assertion-helpers
Type-safe assertion utilities for defensive programming in TypeScript applications.
Installation
npm install @rightcapital/assertion-helpers
# or
pnpm add @rightcapital/assertion-helpers
# or
yarn add @rightcapital/assertion-helpersUsage
import { AssertionHelpers } from '@rightcapital/assertion-helpers';
// Basic assertion
AssertionHelpers.assert(user.age >= 18, 'User must be at least 18 years old');
// Non-nullable assertion with type narrowing
AssertionHelpers.assertNonNullable(user, 'User cannot be null');
// user is now typed as NonNullable<T>
// Ensure with type guard
const admin = AssertionHelpers.ensure(
currentUser,
isAdminUser,
'Admin required',
);
// admin is now typed as AdminUserAgent Skills
This package ships with an Agent Skill that teaches AI coding agents (Claude Code, Cursor, etc.) how to use the assertion-helpers API correctly, following the npm-based Agent Skills Convention.
Automatic discovery (recommended)
If your project uses skills-npm, the
skill is discovered automatically from node_modules:
npx skills-npmManual installation
You can also install the skill directly using the
skills CLI:
npx skills add https://github.com/RightCapitalHQ/frontend-libraries/tree/main/packages/assertion-helpers/skillsAPI Reference
See the generated documentation for detailed API reference.
