ban-type-assertions

ban-type-assertions is a skill for Codex from zacharygcook/agent-skills. It costs 54 tokens per session (517 once invoked), scanned A, original, MIT.

A TypeScript policy and workflow that forbids type assertions, such as forcing a value to be treated as another type without proof.

In plain words
What is it for?
Use it to add the relevant ESLint rule, remove unsafe casts, validate external data, narrow types through control flow, and improve unclear type contracts.
Why use it?
It reduces hidden type errors by requiring the compiler or runtime validation to establish that data has the expected shape.

Skill for Codex

Written for Codex: agents/openai.yaml present.

Good fit Use it to add the relevant ESLint rule, remove unsafe casts, validate external data, narrow types through control flow, and improve unclear type contracts.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/zacharygcook/agent-skills/ban-type-assertions
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 zacharygcook/agent-skills --skill ban-type-assertions
Clone the repo
git clone --depth 1 https://github.com/zacharygcook/agent-skills

Made for: 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 ban-type-assertions

README.md
[![agentmods](https://agentmods.dev/badge/skills/zacharygcook/agent-skills/ban-type-assertions/github.svg)](https://agentmods.dev/skills/zacharygcook/agent-skills/ban-type-assertions)
Your own site
<a href="https://agentmods.dev/skills/zacharygcook/agent-skills/ban-type-assertions"><img src="https://agentmods.dev/badge/skills/zacharygcook/agent-skills/ban-type-assertions/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 ban-type-assertions

Your own site · 80×15
<a href="https://agentmods.dev/skills/zacharygcook/agent-skills/ban-type-assertions"><img src="https://agentmods.dev/badge/skills/zacharygcook/agent-skills/ban-type-assertions.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 54 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 517 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 original No closer match found 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.00054 $0.00517
Opus 5 $0.00027 $0.00259
Sonnet 5 $0.00011 $0.00103
Haiku 4.5 $0.00005 $0.00052

Measured 10d ago against content hash d732a549c78a, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

ban-type-assertions 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 10d 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.

skills/ban-type-assertions/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.

Ban Type Assertions

Configure @typescript-eslint/consistent-type-assertions with assertionStyle: "never", then replace assertions with code the compiler or runtime can verify. Treat as const according to the repository's explicit policy.

Decision Order

1. Validate external data

Parse JSON, network responses, storage, database rows, messages, and other untrusted inputs with the repository's runtime schema library.

// Avoid
const value = JSON.parse(raw) as Payload

// Prefer
const value = PayloadSchema.parse(JSON.parse(raw))

Use non-throwing parse APIs where failure needs structured handling or request context.

2. Narrow with control flow

Use discriminated unions, exhaustive switch, typeof, instanceof, and in when TypeScript can prove the result.

if (error instanceof Error && "code" in error) {
  handleCode(error.code)
}

3. Improve the API or types

Fix overly broad return types, generic inference, duplicate domain types, and missing package contracts. Prefer satisfies when checking an object without changing its inferred type.

4. Document a genuine exception

Use a narrow lint suppression only for an unavoidable library/type-system gap. Explain why it is safe and why normal narrowing cannot work. Do not quietly raise a ratchet threshold.

Avoid Disguised Assertions

A custom predicate returning value is T is still an assertion unless its checks fully establish T. Use schema validation for rich object shapes. Do not replace one cast with a weak guard that only checks one property.

Rollout

  1. Locate all TypeScript packages and their ESLint configurations.
  2. Enable the rule consistently.
  3. Inventory violations and classify boundary, narrowing, API-design, and unavoidable cases.
  4. Fix violations package by package.
  5. Add a CI check or zero-tolerance report if repository lint scope can miss files.
  6. Run lint, typecheck, focused tests, the full suite when practical, and unused-export checks after shared-type changes.

Read the full file on GitHub · 58 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 10d ago First seen · 58 lines · 54 tokens per session scan A d732a549c78a

Subscribe to this mod's changes

ban-type-assertions is a skill published in the GitHub repository zacharygcook/agent-skills (2 stars, last pushed 1mo ago), licensed MIT. It adds 54 tokens to every session and 517 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

architecture-audit

Systematic architecture audit and refactoring methodology for Rust + TypeScript codebases. Use when performing refactoring, cleanup, unification, code review, dead code removal, module reorganization, or tech debt elimination. Ensures no naming confusion, semantic overloading, hidden defaults, duplicate logic, or…

org2AI/ORG2 · 70 tokens

bun-toolkit

JS/TS/JSX toolkit with Bun awareness. Use when using Bun as a runtime, test runner, or package manager in JavaScript and TypeScript projects.

saski/arnesto · 37 tokens

ts-debug

TypeScript/Node debugging expert. Use when the user needs to debug, profile, or trace TypeScript or Node.js code — e.g. "how do I debug this", "find the memory leak", "why is this slow", "add a breakpoint", "profile this function", "why won't the process exit".

berekvolgyipeter/dotclaude · 68 tokens

typescript-conventions

Use when writing, reviewing, or refactoring TypeScript or JavaScript code — naming conventions, type annotations, private fields, null vs. undefined, async/await pitfalls, and module structure.

andr-ca/agentharness · 43 tokens

typescript

Write, review, and refactor TypeScript for readability, type safety, and runtime correctness (Node.js/React/shared libs). Use when creating TS modules, modeling domain types, handling errors (Result/Either), validating external inputs (Zod/io-ts), organizing imports, or preventing cyclic dependencies. NOT for choosing…

bricerising/enterprise-software-playbook · 81 tokens

setup-ts-deep-modules

Wire dependency-cruiser into a TypeScript repo so each package is a deep module — implementation hidden in subfolders, reachable only through its entry-point files. User-invoked.

tt-a1i/matt-skills-with-to-goal · 44 tokens