knitbrain: Instructions file for Claude Code

CLAUDE.md

knitbrain CLAUDE.md is an instructions file for Claude Code from PDgit12/knitbrain. It costs 892 tokens per session, scanned C, original, MIT.

Project instructions for knitbrain, a TypeScript service that gives AI agents tools for session memory, learning, task classification, and self-checks. They describe the required session-start and verification steps.

In plain words
What is it for?
Use them when developing knitbrain, loading or continuing a session, verifying claims, running its checks, or testing changes against the installed build.
Why use it?
They reduce mistakes caused by stale knowledge or unfinished work and require the agent to classify or run a task before saving new learnings or handoffs.

Instructions file for Claude Code

Written for Claude Code: the file is CLAUDE.md.

This is PDgit12/knitbrain's own configuration. It tells Claude Code how to work on knitbrain itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything knitbrain configures →

Reuse

Borrowing it

Nothing to install: this file belongs to PDgit12/knitbrain. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/PDgit12/knitbrain/main/CLAUDE.md
Clone the repo
git clone --depth 1 https://github.com/PDgit12/knitbrain

Made for: Claude Code.

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 knitbrain CLAUDE.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/pdgit12/knitbrain/claude-md/github.svg)](https://agentmods.dev/instructions/pdgit12/knitbrain/claude-md)
Your own site
<a href="https://agentmods.dev/instructions/pdgit12/knitbrain/claude-md"><img src="https://agentmods.dev/badge/instructions/pdgit12/knitbrain/claude-md/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 knitbrain CLAUDE.md

Your own site · 80×15
<a href="https://agentmods.dev/instructions/pdgit12/knitbrain/claude-md"><img src="https://agentmods.dev/badge/instructions/pdgit12/knitbrain/claude-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 892 This file is loaded in full into every session.
When invoked 892 The same file — it is already loaded in full.
Security scan C 1 finding. 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.00892 $0.00892
Opus 5.5 $0.00357 $0.00357
Sonnet 5.5 $0.00178 $0.00178
Haiku 4.5 $0.00089 $0.00089

Measured 2mo ago against content hash 4d9447244c54, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade C, and why

knitbrain CLAUDE.md scanned grade C with 1 finding 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 2mo 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.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

Always `rm -rf dist && npm run verify` before claiming green — stale dist masks build-order bugs. Local rebuild note: `build` re-chmods the three dist entrypoints (a globally symlinked install breaks otherwise).
CLAUDE.md · 66 lines

How it starts

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

knitbrain

TypeScript project (Node ≥18, ESM, vitest). This repo IS the knitbrain product — if a knitbrain MCP server is connected while developing here, note it runs the globally installed build, not your working tree; rebuild + reinstall (npm run build && npm install -g .) and reconnect to test local changes.


Session start

First action: call knitbrain_load_session — returns last handoff, top learnings, false positives. If it reports unfinished work, resume that first.

Adherence gate: close-the-loop writes (knitbrain_record_learning, knitbrain_skill_save, knitbrain_save_handoff) are blocked until knitbrain_classify_task/knitbrain_run ran this session (KNITBRAIN_STRICTNESS, default block).

Tool surface highlights (37 tools)

  • knitbrain_verify_claim — settle a codebase claim before LEARN. Caveat: the session MCP roots at the launch cwd — settle knit-brain facts by source + tests + built dist when the root is elsewhere.
  • knitbrain_self_check — keystone: audits all four invariants (anti-sycophancy, anti-stale, anti-drift, adherence) in one PASS/FAIL pass.
  • knitbrain_run_loop — one judge→iterate cycle per call; your verify_cmd is the hard gate.
  • knitbrain_search_code — retrieval layer: query → ranked function-level chunks + graph-related files, score-gated. Search BEFORE reading; knitbrain_read only the hits.
  • knitbrain_read / knitbrain_optimize / knitbrain_retrieve — compression loop; exact original always one retrieve away. Data-tool JSON responses are never skeletonized (machine contract).
  • Note: big tool responses may come back skeletonized with a trailing ⟨recall:hash⟩ — strip it before JSON-parsing a tool result.

Project Map

Entry points: dist/lib.js, dist/index.js, dist/proxy/index.js, dist/hooks/index.js, src/index.ts High-fanout (change carefully): src/ccr/store.ts, src/tokenizer.ts, src/engine/feedback.ts, src/engine/memory.ts, src/engine/knowledge.ts — check knitbrain_query_dependents before touching. Largest: src/mcp/tools.ts, scripts/production-audit.mjs, src/learn.ts

Read the full file on GitHub · 66 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. 2mo ago First seen · 66 lines · 892 tokens per session scan C 4d9447244c54

Subscribe to this mod's changes

knitbrain CLAUDE.md is an instructions file published in the GitHub repository PDgit12/knitbrain (6 stars, last pushed 6d ago), licensed MIT. It adds 892 tokens to every session, about $0.0036 per session on Opus 5.5. A static security scan graded it C with 1 finding (recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

knitbrain CLAUDE.md compared with instructions from other repositories

knitbrain CLAUDE.md next to 6 instructions from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
knitbrain CLAUDE.mdPDgit12/knitbrainInstructions file66d agoMITC892Claude Code
vscode buildNext.instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA9,719GitHub Copilot
next.js AGENTS.mdvercel/next.jsInstructions file143ktodayMITA7,461Codex, OpenCode
langchain AGENTS.mdlangchain-ai/langchainInstructions file149kyesterdayMITA4,680Codex, OpenCode
vscode oss-third-party-notices.instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA5,516GitHub Copilot
vscode copilot-instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA3,093GitHub Copilot
deepseek-harness AGENTS.mddeepseek-ai/deepseek-harnessInstructions file274k2d agoMITA4,313Codex, OpenCode