kartograf AGENTS.md

Repository guidance for coding agents working on kartograf, a tool that builds a searchable map of a project's code and makes it available to AI agents.

In plain words
What is it for?
Building, testing, installing, and changing kartograf while following its Makefile, language-adapter layout, and SQLite requirements.
Why use it?
It records the project's build commands, structure, and hard-won rules so agents do not repeat known mistakes or run commands that are expected to fail.

Instructions file for CodexOpenCode

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/dev-manul/kartograf/agents-md
Clone the repo
git clone --depth 1 https://github.com/dev-manul/kartograf

Made for: Codex, OpenCode.

Per session 1,319 This file is loaded in full into every session.
When invoked 1,319 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.01319 $0.01319
Opus 5 $0.00660 $0.00660
Sonnet 5 $0.00264 $0.00264
Haiku 4.5 $0.00132 $0.00132

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

Security

Grade A, and why

kartograf AGENTS.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.

AGENTS.md · 115 lines

How it starts

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

AGENTS.md

Guidance for AI agents working in this repository.

What this is

kartograf builds a code map (symbols, references, call graph) of a project into SQLite and serves it to AI agents over MCP (stdio). Tree-sitter parsing, language-agnostic core, PHP/Go/TS adapters, an optional type-inference enrichment layer (go/types, PHPStan).

Build & test

cgo is required (tree-sitter, mattn/go-sqlite3) and so is the sqlite_fts5 build tag — a compile guard (internal/core/store/fts5guard.go) fails the build without it. Always go through the Makefile:

make check      # vet + test + fmt + build — run before every commit
make install    # go install into $GOPATH/bin (MCP configs point there)

Plain go build ./... will fail with BUILD_WITH_TAG_sqlite_fts5... — that is intentional, add -tags sqlite_fts5 or use make.

Layout

  • cmd/kartograf — CLI (cobra): index, serve, enrich, outline, hidden parse-tree.
  • internal/core/model — language-neutral types (Symbol, Ref, Import, FileIndex). Nothing language-specific belongs here.
  • internal/core/lang — adapter contract + registry.
  • internal/core/indexer — walk (gitignore-aware), worker pool, mtime/sha256 change detection, go.mod module map collection.
  • internal/core/store — SQLite schema, bulk/incremental writers, FTS5, enrichment table.
  • internal/core/query — read side used by MCP tools.
  • internal/lang/php, internal/lang/golang, internal/lang/ts — tree-sitter adapters.
  • internal/enrich — go/types pass and PHPStan rule scaffolding + JSONL import.
  • internal/mcpserver — MCP tool definitions.

Hard-won rules (do not relearn these the hard way)

  • Schema changes: any change to the SQLite schema requires bumping schemaVersion in internal/core/store/store.go. A mismatch silently deletes and rebuilds the database — that is the designed migration strategy; never write ALTER migrations.
  • FQN dialects: PHP App\Ns\Class::method(), Go module/pkg.Type.Method(), TS path/module#Class.method() (module = extensionless file path, trailing /index stripped). Symbol IDs prefix the language (php:..., go:..., ts:...). Query helpers (methodSplit, memberSep, suffix lookup) must stay separator-agnostic across all dialects.
  • tree-sitter node kinds: never trust documentation or memory — dump the real CST with kartograf parse-tree file.{php,go} (hidden command) and verify. Grammar quirks live in the adapter tests' testdata/ fixtures; extend those fixtures when touching extraction.
  • MCP output schemas: Claude Code rejects tools whose outputSchema is not a JSON object — wrap list results in a struct ({results: [...]}), never return a bare slice as the Out type.
  • PHPStan enrichment: the rule class is loaded via --autoload-file (bootstrapFiles is too late for DI container construction). Edges travel as pseudo-errors with identifier kartograf.edge through --error-format=json — do NOT switch to a side-channel output file: PHPStan's result cache skips unchanged files and would silently drop their edges.
  • Enrichment lifecycle: .kartograf/enrich.<source>.jsonl is the source of truth — at the root and in every nested project directory (enrich.Discover walks the tree past .git/vendor/dot-dirs/excludes). ext_edges are keyed by origin (root-relative path of the exchange file) and replaced wholesale per origin on import, auto-imported by index/serve on mtime change, and dropped when the file is deleted. Tool-reported paths resolve inside the owning project first (Exchange.Prefix), then root-relative, then by longest suffix.
  • TS specifics: JSX component renders are calls edges with a () target so they join function-component FQNs; unqualified names resolve only through imports or file-local declarations (JS scoping — unknown names are globals and are skipped); imports through barrel files (index.ts re-exports) stay heuristic and do not join the graph — a known limitation.
  • Vendor code is indexed shallow (SkipRefs): declarations and hierarchy only. Don't emit call edges from vendor files.
  • Bulk vs incremental writes: an empty database takes BeginBulkWrite (indexes/triggers dropped, FTS rebuilt once at commit). Incremental runs rely on the FTS triggers; keep both paths working when touching the store.

Read the full file on GitHub · 115 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. 2d ago First seen · 115 lines · 1,319 tokens per session scan A 685ad82f518e

Subscribe to this mod's changes

kartograf AGENTS.md is an instructions file published in the GitHub repository dev-manul/kartograf (2 stars, last pushed 5d ago), licensed MIT. It adds 1,319 tokens to every session, about $0.0066 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.