templates/skills/languages/typescript/SKILL.md
TypeScript language rules with strict mode, testing, linting, and CI/CD best practices
npx skillsauth add hivellm/rulebook TypeScriptInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
CRITICAL: Execute these commands after EVERY implementation (see AGENT_AUTOMATION module for full workflow).
# Complete quality check sequence:
npm run type-check # Type checking
npm run lint # Linting (0 warnings required)
npm run format # Code formatting
npm test # All tests (100% pass required)
npm run test:coverage # Coverage check (95%+ required)
npm run build # Build verification
# Security audit:
npm audit --production # Vulnerability scan
npm outdated # Check outdated deps (informational)
CRITICAL: Use TypeScript 5.3+ with strict mode enabled.
{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "node",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
}
}
CRITICAL: After implementing ANY feature, you MUST run these commands in order.
IMPORTANT: These commands MUST match your GitHub Actions workflows to prevent CI/CD failures!
# Pre-Commit Checklist (MUST match .github/workflows/*.yml)
# 1. Type check (matches workflow)
npm run type-check # or: tsc --noEmit
# 2. Lint (MUST pass with no warnings - matches workflow)
npm run lint
# 3. Format check (matches workflow - use same command as CI)
npx prettier --check 'src/**/*.ts' 'tests/**/*.ts'
# 4. Run all tests (MUST pass 100% - matches workflow)
npm test
# 5. Build (MUST succeed - matches workflow)
npm run build
# 6. Check coverage (MUST meet threshold)
npm run test:coverage
If ANY of these fail, you MUST fix the issues before committing.
eslint.config.js or .eslintrc.jsoneslint src/**/*.tseslint src/**/*.ts --fixExample ESLint config:
{
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"rules": {
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
"@typescript-eslint/explicit-function-return-type": "warn",
"@typescript-eslint/no-explicit-any": "warn"
}
}
.prettierrc.jsonprettier --write "src/**/*.ts"Example Prettier config:
{
"semi": true,
"trailingComma": "es5",
"singleQuote": true,
"printWidth": 100,
"tabWidth": 2
}
/tests directory or co-located *.test.ts filesvitest or vitest --watch for developmentnpm test command MUST include --run flag
package.json: "test": "vitest --run"npm test (do NOT add --run argument)npm run test:watchExample test structure:
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import { myFunction } from './my-module';
describe('myFunction', () => {
beforeEach(() => {
// Setup
});
afterEach(() => {
// Cleanup
});
it('should handle valid input', () => {
const result = myFunction('input');
expect(result).toBe('expected');
});
it('should throw on invalid input', () => {
expect(() => myFunction('')).toThrow('Invalid input');
});
});
CRITICAL: Use consistent package manager across team.
package-lock.json, pnpm-lock.yaml, or yarn.lock)Check for latest versions:
npm view <package> versionsDependency Guidelines:
"1.2.3")"^1.2.3")npm audit or pnpm audit for securityany: Avoid any type - use unknown and type guardsas - prefer type guardsExample type-safe code:
// Good: Type guard
function isString(value: unknown): value is string {
return typeof value === 'string';
}
function process(input: unknown): string {
if (isString(input)) {
return input.toUpperCase();
}
throw new Error('Invalid input');
}
// Bad: Type assertion
function processUnsafe(input: unknown): string {
return (input as string).toUpperCase(); // Runtime error if not string
}
Example:
export class ValidationError extends Error {
constructor(
message: string,
public readonly field: string
) {
super(message);
this.name = 'ValidationError';
}
}
export function validate(data: unknown): Data {
if (!isValidData(data)) {
throw new ValidationError('Invalid data structure', 'data');
}
return data;
}
project/
├── package.json # Package manifest
├── tsconfig.json # TypeScript config
├── vitest.config.ts # Test config
├── README.md # Project overview
├── CHANGELOG.md # Version history
├── AGENTS.md # AI assistant rules
├── src/
│ ├── index.ts # Main entry point
│ ├── types.ts # Type definitions
│ └── ...
├── tests/ # Test files
├── dist/ # Compiled output (gitignored)
└── docs/ # Project documentation
import/export)"type": "module" in package.json.js extensions in imports for Node.js compatibilitymoduleResolution: "node" in tsconfig.jsonExample:
// Good: ES modules with .js extension
import { myFunction } from './my-module.js';
export { myFunction };
export default class MyClass {}
CRITICAL: GitHub Actions cache: 'npm' requires package-lock.json to be committed.
package-lock.json from .gitignorecache: 'npm' in setup-node actionnpm ci (not npm install) for reproducible buildsMust include GitHub Actions workflows for:
typescript-test.yml)typescript-lint.yml)typescript-build.yml)research
Create structured analyses with numbered findings, execution plans, and task materialization
research
Author a rulebook task spec interactively — research, draft, ask the user clarifying questions, confirm, then create the tasks in rulebook ready for /rulebook-driver. Use when the user wants to plan/spec a feature before implementing.
development
Behavioral guidelines to reduce common LLM coding mistakes — overcomplication, sloppy refactors, hidden assumptions, weak goals. Use when writing, reviewing, or refactoring code. Auto-applies; invoke explicitly via /karpathy-guidelines or 'follow karpathy discipline'.
data-ai
Autonomous AI agent loop for iterative task implementation (@hivehub/rulebook ralph)