Agent Native

no-bare-casts

This skill enforces a decision tree for TypeScript casts, requiring developers to eliminate bare `as` casts through type refinement, runtime checks, or using…

by PrismaOfficial publisherNot reviewed

Identity proven by GitHub's verified organisation badge (prisma)

Agents
Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode, claude.ai and API
License
Apache-2.0 (permissive)
Pin
55458c4pinned Oct 9, 2026
Context cost
about 650 tokenswhen the skill loads
GitHub stars
415on prisma/prisma-next
Scripts
None found

What it does

“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.”
The author's description, from SKILL.md

Generated summary from the skill's own text

This skill enforces a decision tree for TypeScript casts, requiring developers to eliminate bare `as` casts through type refinement, runtime checks, or using approved helper functions like `castAs` and `blindCast` with documented reasoning.

When to use it

  • Reviewing TypeScript code with type assertion issues
  • Refactoring production code to reduce unsafe casts
  • Enforcing type safety standards in a codebase
  • Converting existing bare casts to auditable forms

When not to

  • Writing test files where casts are acceptable for stubbing
  • Projects not using TypeScript or strict type checking
  • When rapid prototyping is prioritized over type safety

Install

These commands install from the publisher's repository and need no account.

skills CLI

npx skills add prisma/prisma-next --skill no-bare-casts

Installs from the repository's default branch, which may have changed since the commit we checked.

GitHub CLI 2.90 or later

gh skill install prisma/prisma-next no-bare-casts@55458c441d2cf452028c22eed21370447720840a

Installs the commit we checked (55458c4).

Copy by hand

Download the folder at 55458c4 and put it in .claude/skills/no-bare-casts for Claude Code and in .agents/skills/no-bare-casts for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode.

Skill folder on GitHub at 55458c4

Copy for your agent

A prompt for any coding agent. It installs this skill from GitHub at the pinned commit, copies the files as they are, and runs nothing unless you ask.

Prompt

Install the agent skill "no-bare-casts" by Prisma.

Source, pinned to commit 55458c441d2cf452028c22eed21370447720840a:
https://github.com/prisma/prisma-next/tree/55458c441d2cf452028c22eed21370447720840a/skills-contrib/no-bare-casts

1. Download that folder at exactly this commit. Do not use the default branch.
2. Copy every file unchanged, keeping the folder structure, into .claude/skills/no-bare-casts/ for Claude Code and .agents/skills/no-bare-casts/ for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode. Create the folders if they do not exist.
3. Do not edit the files, and do not run any script in the folder unless I ask you to.
4. When you are done, list the files you copied and where you put them.

Listing and checks: https://www.agentnative.dev/skills/prisma/no-bare-casts

SKILL.md at the pin

---
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 '@prisma-next/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.

From prisma/prisma-next at 55458c4, shown as plain text under its license: Apache-2.0 (permissive). The license text is in LICENSE.

View SKILL.md on GitHub at 55458c4

Files

1 file, 2.8 KB in total. Each file has a sha256 in the pin's manifest; the first 12 characters are shown.

Skill folder on GitHub at 55458c4
All 44 skills from Prisma

More from Prisma

  • prisma-8

    This skill helps agents work with Prisma 8, a contract-first data layer for TypeScript projects.

    Contains scripts

    Claude Code, Codex, Cursor +3 · about 3.5K tokens · pinned 6 days ago

  • adr-review

    This skill reviews Architecture Decision Records (ADRs) from a fresh perspective, identifying clarity and structural issues, then rewrites them for future…

    Claude Code, Codex, Cursor +4 · about 590 tokens · pinned 6 days ago

  • ast-visitor-pattern

    This skill teaches agents to use the visitor pattern with frozen subclasses for discriminated unions that need multiple dispatch sites.

    Claude Code, Codex, Cursor +4 · about 710 tokens · pinned 6 days ago

  • bumping-biome

    Updates the biome code formatter package to a specified version using pnpm, renames configuration files to biome.jsonc format, updates schema references, and…

    Claude Code, Codex, Cursor +4 · about 290 tokens · pinned 6 days ago

  • contrib-pr

    This skill guides external contributors through opening a pull request against prisma-next by following the project's contribution guidelines.

    Claude Code, Codex, Cursor +4 · about 2.2K tokens · pinned 6 days ago

  • create-pr

    This skill creates a GitHub pull request with a Linear-ticket-prefixed title and a decision-led narrative description for the prisma-next repository.

    Claude Code, Codex, Cursor +4 · about 4.3K tokens · pinned 6 days ago

All Coding workflow skills
  • coding-workspace-fixture

    This skill lets the agent evaluate and modify a small TypeScript project located in the coding-workspace-fixture directory.

    by SentryOfficial publisher

    Contains scripts

    Claude Code, Codex, Cursor +3 · about 56 tokens · pinned 6 days ago

  • datadog-app

    This skill guides developers building Datadog Apps with TypeScript, React, and the scaffolder toolchain.

    by DatadogOfficial publisher

    Claude Code, Codex, Cursor +4 · about 610 tokens · pinned 6 days ago

  • ban-type-assertions

    This skill enables the TypeScript ESLint rule that bans `as` type assertions in a package, replacing them with compiler-verified alternatives like Zod…

    by FactoryOfficial publisher

    Claude Code, Codex, Cursor +4 · about 1.6K tokens · pinned 6 days ago

  • practice-registry

    This skill checks Scala, Python, TypeScript, JavaScript, and Rust code against company-specific coding practices before generation, during editing, and before…

    by WriterOfficial publisher

    Claude Code, Codex, Cursor +4 · about 410 tokens · pinned 6 days ago

  • typescript-lsp

    This skill provides TypeScript Language Server Protocol integration to search and explore TypeScript/JavaScript codebases by symbols, types, and references.

    by You.comOfficial publisher

    Claude Code, Codex, Cursor +4 · about 1.6K tokens · pinned 6 days ago

  • appscript

    This skill enables agents to develop, edit, push, and deploy Google Apps Script projects using the clasp CLI from the terminal.

    by SMKeramatiCommunity

    Claude Code, Codex, Cursor +4 · about 3.3K tokens · pinned 6 days ago

The skills listed here are third-party software, collected from public GitHub repositories as a catalog of recent skills and provided as is. Agent Native does not write or control them and is not responsible for any harm, loss or damage caused by installing or using them. Labels and checks describe what we saw at one commit and are not a guarantee. Read a skill's files before you run it. Terms of use