1-type-honesty — Claude Code rule: what it does, how to install
1-type-honesty prevents dangerous TypeScript casts like any and eliminates compiler error suppressions in source code.
MIT ★ 571 updated 2026-10-29
.claude/rules/1-type-honesty.mdWhat 1-type-honesty does
This rule targets src/**/*.ts and tests/**/*.ts to stop unsafe type broadening. It completely bans as unknown as, as any, and as never.
Inside src/, neither @ts-expect-error nor @ts-ignore is permitted. Biome's noTsIgnore rule rejects the latter everywhere in the repository. The only exception is @ts-expect-error inside tests when verifying that invalid code fails compilation.
Every surviving type cast must be documented with its rationale in CASTS_ALLOWED. Compliance across both scopes is verified by scripts/check-cli-type-honesty.mjs executed from the repository root.
What it helps with
- eliminate unsafe TypeScript casts like
as anyandas never - prevent compiler error suppression in production source files
- verify deliberate type errors in test files via
@ts-expect-error - maintain a documented allowlist of casts via
CASTS_ALLOWED
Example prompts for the agent
- Refactor this module to pass 1-type-honesty without using any
- Check this TypeScript file against the type honesty rules
- Write a test verifying this invalid type using
@ts-expect-error
How to install 1-type-honesty
Manually: put the files in place
.claude/rules/1-type-honesty.mdThe paths frontmatter field limits the files
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.cursor/rules/1-type-honesty.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/1-type-honesty.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/1-type-honesty.mdManually: put the files in place
.clinerules/1-type-honesty.mdStep by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use
Questions about 1-type-honesty
How to install 1-type-honesty in Claude Code?
Place the rule file at .claude/rules/1-type-honesty.md in your project root.
What does 1-type-honesty enforce?
It bans casts to any or never, blocks @ts-ignore across the codebase, and restricts @ts-expect-error strictly to tests.
How can valid type casts bypass the rule?
Any intentional cast must be recorded in CASTS_ALLOWED alongside an explanation, then checked via scripts/check-cli-type-honesty.mjs.
Source text
1-type-honesty.md · MIT
--- description: Apply to every cast; a value is never widened away from the type it holds. paths: - "src/**/*.ts" - "tests/**/*.ts" --- # Type Honesty - No `as unknown as`, `as any`, `as never`. - No `@ts-expect-error` or `@ts-ignore` in `src/`; biome's `noTsIgnore` refuses the latter everywhere. - A test proving non-compilation may use `@ts-expect-error`. - `scripts/check-cli-type-honesty.mjs` enforces both scopes, from the repository root. - `CASTS_ALLOWED` lists each surviving cast with its reason.
© ai-driven-dev · MIT · ai-driven-dev/framework