Skip to content

No Bare Casts Guide

Makes the agent avoid unsafe TypeScript 'as' casts and follow a fixed decision tree before using one.

Repository
prisma/orm
Stars
47,663
Licence
Apache-2.0
Files
1 file

What it does

When the agent writes or edits TypeScript production code, this skill tells it to avoid plain 'as' type casts, which silence the compiler without proving anything. Instead it works through a set of alternatives in order: tightening types, adding runtime type checks, restructuring generics, using 'satisfies', and only as a last resort a documented 'blindCast' helper that requires a specific written reason. Test files are exempt.

Great for

  • TypeScript teams in the Prisma codebase or similar repos enforcing strict type safety
  • Developers reviewing or refactoring code that is full of 'as' casts
  • Maintainers who want a consistent, auditable way to handle unavoidable type escapes

Skip it if

  • Projects that do not use the '@internal/utils/casts' helpers, since the agent would be pointed at imports that do not exist there (the skill assumes Prisma's internal layout)
  • Quick prototypes or test code where casts are acceptable, as the skill itself exempts tests and may slow down throwaway work
  • Non-TypeScript projects, where the rules do not apply

Try asking

  • “Refactor this function that uses 'as unknown as' so it no longer needs a cast”
  • “Review this pull request for bare 'as' casts and suggest alternatives”
  • “I'm touching this file that has an 'as' cast; convert it to an accepted form”
  • “Add a type predicate instead of casting this API response”
Step-by-step guide: how to use No Bare Casts GuideInstall, first run, examples, tips and FAQs

Install in 3 steps

  1. 1

    Download the skill

    The ZIP contains the 1 original files, the Apache-2.0 licence and an attribution note.

    no-bare-casts.zip
  2. 2

    Add it to your agent

    Claude Code (all projects)

    mkdir -p ~/.claude/skills && unzip no-bare-casts.zip -d ~/.claude/skills/

    Claude Code / Agent SDK (this project only)

    mkdir -p .claude/skills && unzip no-bare-casts.zip -d .claude/skills/

    Claude apps (web/desktop): Settings → Capabilities → Skills → Upload skill, and choose the ZIP.

  3. 3

    Ask for the task

    No special command needed — the agent reads the skill's description and loads it when your request matches. Try one of the prompts above.

Get better results

  • Install in a repo that actually contains '@internal/utils/casts', or adapt the import path and helper names before use
  • Ask the agent to explain which step of the decision tree it used, so reviewers can check the reasoning
  • Expect stricter, sometimes slower edits; the skill pushes the agent to refactor types rather than cast

What's inside

  • SKILL.md

Redistributed unmodified from prisma/orm under the Apache-2.0 licence. The assessment was drafted with AI from the skill's files on 2026-10-29. Skills can instruct your agent to run code — read SKILL.md and any scripts before installing.