substrate-first

substrate-first is a skill for Claude Code, Codex from katopz/katgpt-rs. It costs 159 tokens per session (11,595 once invoked), scanned A, original, MIT.

A pre-coding check and code audit for a multi-repository workspace. It looks for existing reusable building blocks before new systems, traits, pipelines, state types, spatial queries, or vocabulary are implemented.

In plain words
What is it for?
Use it before adding a new system or when reviewing existing code to find reusable substrate, detect duplicated implementations, and verify that new work builds on the shared code.
Why use it?
It helps prevent parallel implementations of functionality that already exists under another name, reducing duplicated and drifting code.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: installed under .agents/ (shared by several agents); mentions AGENTS.md.

Not installable: its command points at a path on the author’s own machine, so it runs nowhere else. The line is /Users/katopz/git.

Install

Getting it into your agent

There is no command for this one: it runs only inside a plugin, and the catalogue could not identify which plugin ships it. The source is linked below.

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 substrate-first

README.md
[![agentmods](https://agentmods.dev/badge/skills/katopz/katgpt-rs/substrate-first.svg)](https://agentmods.dev/skills/katopz/katgpt-rs/substrate-first)
Your own site
<a href="https://agentmods.dev/skills/katopz/katgpt-rs/substrate-first"><img src="https://agentmods.dev/badge/skills/katopz/katgpt-rs/substrate-first.svg" alt="Measured on agentmods" height="20"></a>
Per session 159 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 11,595 The whole file, excluding the scripts and references it only reads on demand.
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.1 $0.00159 $0.11595
Opus 5 $0.00079 $0.05797
Sonnet 5 $0.00032 $0.02319
Haiku 4.5 $0.00016 $0.01159

Measured yesterday against content hash 6ad0ea024c1e, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

substrate-first 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 yesterday.

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.

.agents/skills/substrate-first/SKILL.md · 366 lines

How it starts

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

Substrate-First — DRY gate + drift audit

The workspace — 18 repos carrying a root BOUNDARY.md as of 2026-09-01, derived by the snippet in Step 2 rather than typed here — has a recurring failure mode: an agent receives a task ("add threat perception"), jumps to implementation without checking existing substrate, and builds a parallel system that duplicates functionality already shipped under a different name. The user then has to catch it manually.

This skill prevents that. It runs in two modes:

  1. Pre-implementation gate — run BEFORE writing code
  2. Existing-code audit — scan for already-shipped DRY violations

Canonical failures (the pattern this skill prevents)

Failure 1 — ThreatField (Issue 047, riir-mmorpg-examples, 2026-08-01)

Built: ThreatField — a spatial hash grid (HashMap<(i32,i32), u32>) for threat perception. Deposited monster positions into cells; NPCs sampled the 3×3 neighborhood.

Already existed: GenericSpatialBelief<T> + target_within_visible_radius()

  • decay_confidence() — the full fog-of-war → belief → decay pipeline in riir-games-shared/src/game_traits/spatial.rs.

Why the grep missed it: The agent searched for "threat field" / "spatial hash". The substrate ships as GenericSpatialBelief / SpatialBelief / confidence_decay. A single-vocabulary grep returns ZERO hits even when the substrate fully exists.

Resolution: Reverted. The plain scan (tick_swarm_emotions) is a simpler POC-scale simplification. The belief-based system is deferred until fog-of-war becomes a gameplay feature.

Failure 2 — Orchard + Motivation in SDK src/ (Issue 490 + Issue 493)

Built: NpcReasonSystem, AppleGrowSystem, OrchardGoal, EmotionField, EmotionAxis, tick_feeling_brain directly in the SDK facade's src/.

Already existed: The boundary rule (riir-game-sdk/AGENTS.md) says "no game logic in src/" + Proposal 019 excludes emotion from the SDK. The substrate belongs in riir-games (in riir-ai).

Read the full file on GitHub · 366 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. yesterday Changed · +1 lines 6ad0ea024c1e
  2. 2d ago Changed · +45 lines 5b0a203233dd
  3. 6d ago First seen · 320 lines · 159 tokens per session scan A 317d412bba4d

Subscribe to this mod's changes

substrate-first is a skill published in the GitHub repository katopz/katgpt-rs (98 stars, last pushed yesterday), licensed MIT. It adds 159 tokens to every session and 11,595 once invoked, about $0.0008 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.

Related

Other skills, from other repositories

systematic-debugging

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.

obra/superpowers · 21 tokens

local-ai-agents

Build local-first AI agents that run entirely on a developer workstation with Microsoft Foundry Local and Qwen function-calling models. Covers Small Language Models (SLMs), the OpenAI-compatible local endpoint, sandboxed local tools, local RAG with Chroma, local MCP servers, hybrid cloud/local routing, and the…

microsoft/ai-agents-for-beginners · 200 tokens

chronicle

Analyze Copilot session history for standup reports, usage tips, session search, and session reindexing. Use when the user asks for a standup, daily summary, usage tips, workflow recommendations, wants to search or find past sessions by keyword/file/PR, wants to reindex their session store, or asks about deleting…

microsoft/vscode · 72 tokens

chat-pet-sprite-creation

Use when creating or changing VS Code chat pet sprite art, sprite sheets, state animations, eye treatments, Stable/Insiders variants, or pet transitions under src/vs/workbench/contrib/chat/browser/widget/media/chatPet.

microsoft/vscode · 53 tokens

cpu-profile-analysis

Analyze V8/Chrome CPU profiles (.cpuprofile) and DevTools trace files (Trace-.json). Use when: profiling performance, investigating slow functions, comparing code paths, finding bottlenecks, analyzing timeToRequest, understanding call trees from sampling profiler data, analyzing layout/paint/rendering, investigating…

microsoft/vscode · 71 tokens

next-cache-components-adoption

Turn on Cache Components in a Next.js app and resolve the blocking routes it surfaces. Use when the user wants to enable, adopt, or migrate to Cache Components, flip the cacheComponents flag, work through a flood of blocking-prerender / instant validation errors, run the cache-components-instant-false codemod, or…

vercel/next.js · 95 tokens