no-bare-casts

no-bare-casts is a skill for Claude Code, Codex from prisma/prisma-next. It costs 52 tokens per session (664 once invoked), scanned A, a copy of no-bare-casts, Apache-2.0.

A TypeScript coding rule for avoiding bare type casts in production code. A type cast tells TypeScript to treat a value as another type, and this rule requires safer alternatives or a stated reason for the exception.

In plain words
What is it for?
Use it when writing or reviewing production TypeScript code that contains a type cast or needs one to silence a type error.
Why use it?
It reduces cases where a cast hides an actual type or runtime problem. The decision process encourages narrower types and runtime checks first.

Skill for Claude CodeCodex ✓ vendor

Written for no agent in particular: nothing here depends on one.

Good fit Use it when writing or reviewing production TypeScript code that contains a type cast or needs one to silence a type error.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/prisma/prisma-next/no-bare-casts
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add prisma/prisma-next --skill no-bare-casts
Clone the repo
git clone --depth 1 https://github.com/prisma/prisma-next

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for no-bare-casts

README.md
[![agentmods](https://agentmods.dev/badge/skills/prisma/prisma-next/no-bare-casts/github.svg)](https://agentmods.dev/skills/prisma/prisma-next/no-bare-casts)
Your own site
<a href="https://agentmods.dev/skills/prisma/prisma-next/no-bare-casts"><img src="https://agentmods.dev/badge/skills/prisma/prisma-next/no-bare-casts/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for no-bare-casts

Your own site · 80×15
<a href="https://agentmods.dev/skills/prisma/prisma-next/no-bare-casts"><img src="https://agentmods.dev/badge/skills/prisma/prisma-next/no-bare-casts.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 52 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 664 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin 100% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00052 $0.00664
Opus 5.5 $0.00021 $0.00266
Sonnet 5.5 $0.00010 $0.00133
Haiku 4.5 $0.00005 $0.00066

Measured 3mo ago against content hash e1791e009331, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

no-bare-casts scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

This is a copy

100% identical to no-bare-casts — 4 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

skills-contrib/no-bare-casts/SKILL.md · 58 lines

How it starts

The opening of the file, as written. The whole thing — 58 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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

import { blindCast, castAs } from '@prisma-next/utils/casts';

Helper signatures

// 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:

// ✅  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)

Read the full file on GitHub · 58 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3mo ago First seen · 58 lines · 52 tokens per session scan A e1791e009331

Subscribe to this mod's changes

no-bare-casts is a skill published in the GitHub repository prisma/prisma-next (406 stars, last pushed 9d ago), licensed Apache-2.0. It adds 52 tokens to every session and 664 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. It is 100% identical to no-bare-casts, differing in 4 lines, and is treated as a copy.

Related

no-bare-casts compared with skills from other repositories

no-bare-casts next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
no-bare-castsprisma/prisma-nextSkill4069d agoApache-2.0A52Claude Code, Codex
no-bare-castsprisma/ormSkill48ktodayApache-2.0A52Claude Code, Codex
aws-sst-developmentsickn33/agentic-awesome-skillsSkill51ktodayMITA26Claude Code
league-akari-shard-developmentLeagueAkari/LeagueAkariSkill4.9k2d agoMITA58Claude Code, Codex
dd-code-generationDataDog/pupSkill1.1ktodayApache-2.0A16Claude Code
typescript-magicianmcollina/skillsSkill2.0k18d agoMITA108Claude Code, Codex
fast-typescript-checkinternet-development/www-sacredSkill1.6k17d agoMITA84Claude Code, Codex