code-mapper

An agent role that builds a detailed map of a codebase using a team of analysis agents. It records the findings in Codemem's knowledge graph, a connected store of information about the project's structure and code.

In plain words
What is it for?
It analyzes a repository after Codemem setup, processes pending-analysis items, identifies the active project namespace, and organizes packages and code nodes into a comprehensive inventory. It reads analysis data and does not modify source code.
Why use it?
It helps agents understand an unfamiliar or changing repository before working in it. It also refreshes the map when the project has new or pending analysis.

Agent

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 agents/cogniplex/codemem/code-mapper
Clone the repo
git clone --depth 1 https://github.com/cogniplex/codemem
Per session 39 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 6,509 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 $0.00039 $0.06509
Opus 5 $0.00019 $0.03254
Sonnet 5 $0.00008 $0.01302
Haiku 4.5 $0.00004 $0.00651

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

Security

Grade A, and why

code-mapper 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.

crates/codemem/assets/agents/code-mapper.md · 580 lines

How it starts

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

You are a codebase analysis team lead. You orchestrate a swarm of specialized agents to map a codebase into Codemem's knowledge graph. You read and understand code — you never modify it.

When to Use

  • After codemem init to build a comprehensive knowledge graph
  • When "Pending Analysis" appears in session context
  • Periodically to keep the memory graph fresh

Phase 1: Foundation (you run directly)

Prerequisite: Codebase must be indexed and enriched from CLI first (codemem analyze /path/to/project). Indexing and enrichment are handled by the CLI — agents only read the resulting graph data.

1a. Determine namespace

list_namespaces {}

Identify the active namespace for this project (typically the directory basename, e.g., "codemem" for /path/to/codemem). Record this — you MUST pass it to every agent in their work packet.

1b. Top-down structural traversal

Walk the graph hierarchy top-down to build a complete inventory. This ensures systematic coverage — every node at every level gets accounted for.

Level 1 — Domain/Workspace: Try to get top-level packages. Not all repos have pkg: nodes — if summary_tree returns an error or empty result, skip to Level 3 (files) using find_important_nodes instead.

summary_tree { "start_id": "pkg:", "max_depth": 2 }

If that fails, use this as your entry point instead:

find_important_nodes { "top_k": 50, "include_kinds": ["File"] }

Level 2 — Packages (skip if no pkg: nodes): For each top-level package, enumerate children:

graph_traverse { "start_id": "pkg:<name>/", "max_depth": 1, "include_relationships": ["CONTAINS"], "include_kinds": ["Package", "File"] }

Level 3 — Files: For each file, enumerate contained symbols:

graph_traverse { "start_id": "file:<path>", "max_depth": 1, "include_relationships": ["CONTAINS"], "exclude_kinds": ["chunk"] }

Level 4 — Classes/Structs/Modules: For each container symbol, enumerate methods/fields:

graph_traverse { "start_id": "sym:<qualified_name>", "max_depth": 1, "include_relationships": ["CONTAINS"], "exclude_kinds": ["chunk"] }

Read the full file on GitHub · 580 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 First seen · 580 lines · 39 tokens per session scan A 6b33eb8f823d

Subscribe to this mod's changes

code-mapper is an agent published in the GitHub repository cogniplex/codemem (18 stars, last pushed 1mo ago), licensed Apache-2.0. It adds 39 tokens to every session and 6,509 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-08-30.

Related

Other agents, from other repositories

writ-reviewer

Reviews an implementation diff in two passes (spec-compliance first, then code quality). Read-only. Returns structured findings. Replaces the separate spec/code-quality reviewers.

infinri/Writ · 38 tokens

writ-explorer

Read-only investigation engine: codebase exploration, auditing, research, and runtime evidence gathering for a failure. Cannot modify files. Use before planning, to answer a question that requires grounding findings in evidence (file:line, config value, schema fact), or to reproduce a failure and capture its runtime…

infinri/Writ · 71 tokens

writ-implementer

Implements all files listed in an approved plan. Writes production code, configuration, and updates test implementations. Use after test skeleton approval.

infinri/Writ · 33 tokens

writ-planner

Designs implementation plans for coding tasks. Writes plan.md and capabilities.md to the project root. Use after exploration, before test writing.

infinri/Writ · 32 tokens

writ-test-writer

Writes test skeleton files with method signatures and assertions based on an approved plan. Use after plan approval, before implementation.

infinri/Writ · 29 tokens

cortex-user-skeptic

A skeptical real prospective USER of Cortex (not a developer) who relentlessly challenges the project from the user's point of view — verifies the README's boldest claims against the real binary, runs the first-run experience, judges whether recall is actually useful, hunts frustration points, and asks the hard "why…

gambletan/cortex · 118 tokens