non-null-assertion

non-null-assertion is a skill for Claude Code from ncaq/konoka. It costs 40 tokens per session (586 once invoked), scanned A, original, Apache-2.0.

A TypeScript coding rule that forbids the non-null assertion operator, the exclamation mark used to tell the compiler a value cannot be missing. It recommends optional chaining, type checks, and null checks instead.

In plain words
What is it for?
Use it when writing or reviewing TypeScript, including code that reads arrays or maps and tests values for existence.
Why use it?
It reduces runtime errors caused by treating missing or undefined values as if they were always present.

Skill for Claude Code

Written for Claude Code: user-invocable in frontmatter.

Part of the web-tasuke plugin — 17 skills shipped together

Good fit Use it when writing or reviewing TypeScript, including code that reads arrays or maps and tests values for existence.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/ncaq/konoka/non-null-assertion
View source ↗ ncaq/konoka
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 ncaq/konoka --skill non-null-assertion
Clone the repo
git clone --depth 1 https://github.com/ncaq/konoka

Made for: Claude Code.

Or install web-tasuke, the plugin that ships this one along with the rest of its 17 skills.

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 non-null-assertion

README.md
[![agentmods](https://agentmods.dev/badge/skills/ncaq/konoka/non-null-assertion/github.svg)](https://agentmods.dev/skills/ncaq/konoka/non-null-assertion)
Your own site
<a href="https://agentmods.dev/skills/ncaq/konoka/non-null-assertion"><img src="https://agentmods.dev/badge/skills/ncaq/konoka/non-null-assertion/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 non-null-assertion

Your own site · 80×15
<a href="https://agentmods.dev/skills/ncaq/konoka/non-null-assertion"><img src="https://agentmods.dev/badge/skills/ncaq/konoka/non-null-assertion.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 40 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 586 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.00040 $0.00586
Opus 5 $0.00020 $0.00293
Sonnet 5 $0.00008 $0.00117
Haiku 4.5 $0.00004 $0.00059

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

Security

Grade A, and why

non-null-assertion 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 4d 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.

plugins/web-tasuke/skills/non-null-assertion/SKILL.md · 79 lines

What it actually says

Non-null Assertion (!)の禁止

Non-null assertion演算子(!)はTypeScriptの型安全性を破壊するため、使用しないでください。

!を付けた時点でコンパイラによるnullチェックが無効化され、実行時エラーの原因になります。

ESLintでも@typescript-eslint/no-non-null-assertionルールとしてよく禁止されています。

代替手段

Optional chaining

値がnullableかもしれない場合は?.で安全にアクセスしてください。

// Bad
const name = users[0]!.name;

// Good
const name = users[0]?.name;
const name = users.at(0)?.name;

Type guardによる絞り込み

Map等からの取得など、型がT | undefinedになる場面ではnullチェックで絞り込んでください。

// Bad
const config = configMap.get(key)!;
applyConfig(config);

// Good
const config = configMap.get(key);
if (config == null) {
  throw new Error(`Config not found for key: ${key}`);
}
applyConfig(config);

filterの使用

filterはtype guardとして機能するため、 nullableな要素の除去に活用できます。 明示的なtype predicateの記述は不要です。

// Bad: non-null assertionで無理やり絞り込む
const names = users.map((u) => u.name!);

// Good: filterで型安全にundefinedを除去(TypeScript 5.5以降)
const names = users.map((u) => u.name).filter((name) => name != null);
// names: string[]

テストコードでの扱い

jestやvitestでexpect(value).toBeDefined()を書いてもTypeScript上はnullableのままです。 Node.jsやvitestのassertを使ってください。

// Bad: expectの後でも型は絞り込まれない
const item = items.find((i) => i.id === targetId);
expect(item).toBeDefined();
expect(item!.name).toBe("foo");

// Good: assertで絞り込む
import assert from "node:assert";
const item = items.find((i) => i.id === targetId);
assert(item != null);
expect(item.name).toBe("foo");
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. 4d ago First seen · 79 lines · 40 tokens per session scan A 9c73cbbbce7d

Subscribe to this mod's changes

non-null-assertion is a skill published in the GitHub repository ncaq/konoka (3 stars, last pushed yesterday), licensed Apache-2.0. It adds 40 tokens to every session and 586 once invoked, about $0.0002 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-09-05.

Related

Other skills, from other repositories

better-auth

Skill for integrating Better Auth - comprehensive TypeScript authentication framework for Cloudflare D1, Next.js, Nuxt, and 15+ frameworks. Use when adding auth, encountering D1 adapter errors, or implementing OAuth/2FA/RBAC features.

secondsky/claude-skills · 53 tokens

bun-bundler

This skill should be used when the user asks about "bun build", "Bun.build", "bundling with Bun", "code splitting", "tree shaking", "minification", "sourcemaps", "bundle optimization", "esbuild alternative", "building for production", "bundling TypeScript", "bundling for browser", "bundling for Node", or…

secondsky/claude-skills · 90 tokens

bun-hot-reloading

Use when implementing hot reloading with Bun (--hot, --watch), HMR, or automatic code reloading during development. Covers watch mode, hot mode, and HTTP server reload.

secondsky/claude-skills · 42 tokens

TypeScript Null Safety Guardrails

Enforce null/undefined safety for changed TypeScript code and suggest safer patterns.

s977043/river-review · 23 tokens

TypeScript Strictness Guard

Enforce TypeScript strictness by reducing any/unsafe assertions and ensuring null handling.

s977043/river-review · 23 tokens

fix-typescript

Fix TypeScript errors with strict anti-reward-hacking rules. ALWAYS use when the user says 'fix type errors', 'fix typescript', 'type-check is failing', or when TypeScript compilation errors need to be resolved. Ensures runtime type safety — fixes root causes instead of silencing errors with casts.

coalesce-labs/catalyst · 70 tokens