Official agent skill

No Bare Casts

by prisma in prisma/orm

Replaces bare `as` casts in production TypeScript with a decision tree of tighter types, type predicates, satisfies and audited cast helpers.

OfficialApache-2.0Auto-check passedDevelopment

Install No Bare Casts

skills CLI
$ npx skills add prisma/orm --skill no-bare-casts -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install prisma/orm no-bare-casts --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/prisma/orm.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills-contrib/no-bare-casts .claude/skills/no-bare-casts && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
no-bare-casts
GitHub stars
48k
Token cost
~705 tokens
SKILL.md length
306 words
Files
1
Skills in repo
20
Repo updated
First seen
Licence
Apache-2.0

At a glance

Replaces bare `as` casts in production TypeScript with a decision tree of tighter types, type predicates, satisfies and audited cast helpers.

  • Works in 6 steps: Tighten the input type. Can the… → Add a runtime check. Can a type… → Restructure a generic. Can a bound or… → …
  • Writing `as` in TypeScript production code and wanting a safer alternative
  • SKILL.md covers Decision tree, Import, Helper signatures and The Reason bar, plus 1 more section
  • Calls pnpm

What it does

Any bare `as` in production TypeScript or TSX is treated as a prompt to work through a decision tree before the cast is written or kept. The steps run in order: tighten the type at the source, add a runtime type predicate, restructure a generic bound, use `satisfies` when you only want a check, use `castAs<T>(value)` when the assertion is purely declarative, and only then reach for `blindCast`.

The `blindCast` helper takes the target type plus a string-literal reason that a reviewer can judge, so a vague reason is grounds to push back. Both helpers are imported from @internal/utils/casts, and test files are exempt. When a file that already contains a bare cast is touched for any reason, the cast should be converted or removed, because the CI check `pnpm lint:casts` rejects pull requests that raise the cast count.

When your agent uses it

  • Writing `as` in TypeScript production code and wanting a safer alternative
  • Silencing a type error with a cast or meeting `as unknown as`
  • Editing a file that already contains bare casts
  • Reviewing a pull request where a cast site needs a justification

Example prompts

  • “This handler uses `as unknown as User` to get past a type error. Fix it properly.”
  • “Convert the bare casts in src/client/query.ts to the accepted forms.”
  • “Review the casts added in this diff and tell me which ones lack a real reason.”

Requirements

  • A TypeScript codebase that provides the blindCast and castAs helpers

Workflow steps

6 steps, taken from the first numbered list in SKILL.md.

  1. Tighten the input type. Can the parameter, generic bound, or return type at the source be made more specific so the cast is unnecessary?
  2. Add a runtime check. Can a type predicate (function isUser(x): x is User) narrow the type at runtime, eliminating the cast?
  3. Restructure a generic. Can a bound or constraint carry the needed information, making the cast unnecessary?
  4. Use satisfies. expr satisfies T checks the type without coercing it and is unaffected by this rule. Prefer it when you want a type-check…
  5. Use castAs(value). When the value already satisfies T and the assertion is purely declarative, castAs is the right form.
  6. Only if none of the above: use blindCast(value). The Reason literal must name the specific compromise in language a reviewer can evaluate.

What it can do on your machine

Read from SKILL.md and the folder at commit 095af7a. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • pnpm

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use pnpm, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

No Bare Casts loads about 705 tokens when it runs. Until then it costs about 51 tokens; SKILL.md has 306 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~51
When it runs · the whole SKILL.md, loaded when a task matches
~705

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from prisma/orm at commit 095af7a, republished under its Apache-2.0 licence (© prisma). 306 words, ~705 tokens.

Download SKILL.mdSave it as .claude/skills/no-bare-casts/SKILL.md (or your agent's skills folder).
name
no-bare-casts
description
Writing `as` in TypeScript or TSX production code, modifying a file that contains a bare `as` cast, silencing a type error with a cast, encountering `as unknown as`, or reviewing a cast site.

No bare as casts

Any bare as in production TypeScript is a signal to stop and work through the decision tree below. Test files (*.test.ts, *.test-d.ts, test/**/*.ts) are exempt — tests use as for stubbing and type assertions and that's fine.

Decision tree

Work through these in order before writing or keeping a cast:

  1. Tighten the input type. Can the parameter, generic bound, or return type at the source be made more specific so the cast is unnecessary?
  2. Add a runtime check. Can a type predicate (function isUser(x): x is User) narrow the type at runtime, eliminating the cast?
  3. Restructure a generic. Can a bound or constraint carry the needed information, making the cast unnecessary?
  4. Use satisfies. expr satisfies T checks the type without coercing it and is unaffected by this rule. Prefer it when you want a type-check, not a coercion.
  5. Use castAs<T>(value). When the value already satisfies T and the assertion is purely declarative, castAs is the right form.
  6. Only if none of the above: use blindCast<T, "Reason">(value). The Reason literal must name the specific compromise in language a reviewer can evaluate.

Import

typescript
import { blindCast, castAs } from '@internal/utils/casts';

Helper signatures

typescript
// Escape hatch — the value is genuinely opaque or unrelated to the target type.
// The Reason literal documents the compromise; the reviewer evaluates it.
function blindCast<TargetType, Reason extends string>(input: unknown): TargetType

// Declarative assertion — the value already satisfies T at runtime.
function castAs<T>(value: T): T

The Reason bar

blindCast is the auditable escape hatch of last resort — not a convenience wrapper. Reach for it only after the decision tree above has been exhausted. The second type argument must be a string literal that a reviewer can act on:

typescript
// ✅  Names the specific constraint
blindCast<User, "deserialized from contract validator; shape has already been checked">(raw)

// ❌  Adds no information — reviewer has nothing to evaluate
blindCast<User, "trust me">(raw)

A vague reason is the reviewer's signal to push back and the author's signal to revisit the type design.

"Convert when you touch"

When you touch a file that contains a bare as cast — even as part of unrelated work — convert it to one of the accepted forms or eliminate it. The CI ratchet (pnpm lint:casts) rejects per-PR cast-count increases; converting on contact is how the total comes down over time.

© prisma, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills-contrib/no-bare-casts of prisma/orm.

Open the folder on GitHubat commit 095af7a

Compare with similar skills

No Bare Casts next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

No Bare Casts compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
No Bare Casts this skillprisma/orm48k—~705Automated safety check: PassApache-2.0
Obsidian Plugin Development Guidelinesgapmiss/obsidian-plugin-skill190—~4.5kAutomated safety check: PassMIT
Strict Programming Practicescode-yeongyu/oh-my-openagent70k—~9.5kAutomated safety check: PassCustom licence
Fallow Setupfallow-rs/fallow-skills129—~1.1kAutomated safety check: PassMIT
LobeHub TypeScript Style Guidelobehub/lobehub83k—~968Automated safety check: PassCustom licence
Typescript Best Practicesjwynia/agent-skills165—~2.5kAutomated safety check: PassMIT

Similar skills

  • Obsidian Plugin Development Guidelines

    gapmiss/obsidian-plugin-skill

    Rules and references for building Obsidian plugins: ESLint rules, TypeScript practices, memory cleanup, API choices, UI standards and the community submission process.

    190 GitHub stars~4.5k tokensUpdated 12 days ago
    DevelopmentAuto-check passed
  • Strict Programming Practices

    code-yeongyu/oh-my-openagent

    Applies strict, type-first coding rules for Python, Rust, TypeScript and Go, loading the matching language reference before the agent writes or edits any code.

    70k GitHub stars~9.5k tokensUpdated today
    DevelopmentAuto-check passed
  • Fallow Setup

    fallow-rs/fallow-skills

    Set up or modernize code-quality tooling for JavaScript and TypeScript projects.

    129 GitHub stars~1.1k tokensUpdated today
    DevelopmentAuto-check passed
  • House rules for TypeScript type safety, async code and imports in the LobeHub codebase, covering inference, error suppression, module augmentation and IO patterns.

    83k GitHub stars~968 tokensUpdated today
    DevelopmentAuto-check passed
  • Typescript Best Practices

    jwynia/agent-skills

    Guide AI agents through TypeScript coding best practices including type safety, error handling, code organization, and architecture patterns.

    165 GitHub stars~2.5k tokensUpdated 7 mo ago
    DevelopmentAuto-check passed
  • Clean Code TS React

    pproenca/dot-skills

    A skill your agent uses when writing, reviewing, or refactoring TypeScript or React code for craftsmanship — naming, function and component shape, error handling, data modeling, tests, and…

    214 GitHub stars~3.1k tokensUpdated 1 mo ago
    DevelopmentAuto-check passed

More from prisma/orm

All 20 skills in this repo
  • Official

    Runs a loop on a GitHub pull request: fetch review state, triage comments into actions, implement them and resolve threads, repeating until nothing actionable is left.

    48k GitHub stars~2.2k tokensUpdated today
    Auto-check passed
  • Official

    Fetches a pull request's canonical review state as JSON, validates it, and renders markdown, a text summary and triage target files from it using bundled scripts.

    48k GitHub stars~767 tokensUpdated today
    Auto-check passed
  • Official

    Implements triaged pull request review actions, commits focused fixes, posts status replies on GitHub and resolves the threads.

    48k GitHub stars~1.7k tokensUpdated today
    Auto-check passed
  • Official

    Runs the triage step of the review-framework loop: reads fetched PR review state, builds `review-actions.json`, validates it and renders `review-actions.md`.

    48k GitHub stars~995 tokensUpdated today
    Auto-check passed
  • Official

    Replaces a plain TypeScript union plus switch statements with frozen subclasses and a visitor interface when several places dispatch on the same variants.

    48k GitHub stars~830 tokensUpdated today
    Auto-check passed
  • Official

    Guides an outside contributor through opening a prisma/orm pull request from a fork that follows CONTRIBUTING.md and passes review on the first round.

    48k GitHub stars~2.3k tokensUpdated today
    Auto-check passed

Works with

Categories

Questions about No Bare Casts

What does No Bare Casts do?

Replaces bare `as` casts in production TypeScript with a decision tree of tighter types, type predicates, satisfies and audited cast helpers. Any bare `as` in production TypeScript or TSX is treated as a prompt to work through a decision tree before the cast is written or kept. The steps run in order: tighten the type at the source, add a runtime type predicate, restructure a generic bound, use `satisfies` when you only want a check, use `castAs<T>(value)` when the assertion is purely declarative, and only then reach for `blindCast`.

When should I use No Bare Casts?

No Bare Casts fits situations like: writing `as` in TypeScript production code and wanting a safer alternative; silencing a type error with a cast or meeting `as unknown as`; editing a file that already contains bare casts; reviewing a pull request where a cast site needs a justification.

How do I install No Bare Casts in Claude Code?

Run `npx skills add prisma/orm --skill no-bare-casts -a claude-code`. Or copy the skill folder (skills-contrib/no-bare-casts in prisma/orm) into .claude/skills/no-bare-casts in your project. Claude Code loads it when a task matches its description.

How do I install No Bare Casts in Codex?

Run `npx skills add prisma/orm --skill no-bare-casts -a codex`. Or copy the skill folder (skills-contrib/no-bare-casts in prisma/orm) into .agents/skills/no-bare-casts in your project. Codex loads it when a task matches its description.

Can I use No Bare Casts in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add prisma/orm --skill no-bare-casts -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/no-bare-casts, .gemini/skills/no-bare-casts, .github/skills/no-bare-casts and .opencode/skills/no-bare-casts in your project.

What does No Bare Casts need to run?

Going by SKILL.md and its folder, No Bare Casts needs the command-line tools its instructions call (pnpm). Our summary lists: A TypeScript codebase that provides the blindCast and castAs helpers.

Does No Bare Casts access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is No Bare Casts safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does No Bare Casts use?

No Bare Casts is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does No Bare Casts use?

About 705 tokens (SKILL.md is roughly 2.8k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to No Bare Casts?

Skills that share tags, products or a category with No Bare Casts: Obsidian Plugin Development Guidelines (gapmiss/obsidian-plugin-skill, 190 stars), Strict Programming Practices (code-yeongyu/oh-my-openagent, 70k stars), Fallow Setup (fallow-rs/fallow-skills, 129 stars) and LobeHub TypeScript Style Guide (lobehub/lobehub, 83k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains No Bare Casts?

prisma (a GitHub organization, an official publisher) maintains it in prisma/orm, which has 47,701 GitHub stars. The repository holds 20 skills in this directory. The repository was last updated on October 6, 2026.

Source: prisma/orm on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.