node-express-boilerplate typescript-assertions.instructions.md

TypeScript editing guidance for avoiding unsafe type assertions, which are statements that tell TypeScript to trust a value without enough proof.

In plain words
What is it for?
Use it when editing TypeScript in src to prefer type narrowing, type guards, satisfies, and const-based type definitions.
Why use it?
It reduces type and lint problems that can appear when changes are merged, especially when broad casts hide incorrect values.

Instructions file for GitHub Copilot

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.

agentmods
npx agentmods add instructions/khaledsaeed18/node-express-boilerplate/typescript-assertions
Clone the repo
git clone --depth 1 https://github.com/KhaledSaeed18/node-express-boilerplate

Made for: GitHub Copilot.

Per session 344 This file is loaded in full into every session.
When invoked 344 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
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 $0.00344 $0.00344
Opus 5 $0.00172 $0.00172
Sonnet 5 $0.00069 $0.00069
Haiku 4.5 $0.00034 $0.00034

Measured 2d ago against content hash 12254ba10340, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

node-express-boilerplate typescript-assertions.instructions.md 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 2d 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.

.github/instructions/typescript-assertions.instructions.md · 36 lines

What it actually says

TypeScript Assertion Safety

Follow this file when touching TypeScript in src/ where merges can introduce assertion-heavy fixes.

Rule

  • Treat type assertions as a last resort.
  • Prefer control-flow narrowing, user-defined type guards, satisfies, and as const + typeof derivation.
  • Do not use double assertions (as unknown as T) unless there is no safe alternative and the boundary is documented.

Preferred Patterns

  • Runtime-to-type derivation:
    • Define constants with as const.
    • Derive unions with typeof Obj[keyof typeof Obj].
  • External input handling:
    • Validate and narrow first, then use strongly typed values.
  • Framework interop edge cases (Express/Node APIs):
    • Use narrow casts on the smallest expression, not on wide objects.

Merge-Fix Checklist

  • Remove newly added broad casts and replace with narrowing where possible.
  • Keep assertions local to integration boundaries.
  • Ensure final code passes the project quality gate in AGENTS.md.

References

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. 2d ago First seen · 36 lines · 344 tokens per session scan A 12254ba10340

Subscribe to this mod's changes

node-express-boilerplate typescript-assertions.instructions.md is an instructions file published in the GitHub repository KhaledSaeed18/node-express-boilerplate (33 stars, last pushed 9d ago), licensed MIT. It adds 344 tokens to every session, about $0.0017 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-30.