Reusable repository maps and task-focused file routing for Claude Code and Codex, generated with Python.
Try it locally · Usage guide · Claude Code setup · Codex setup · License
Generate a durable context pack so coding agents can start from a repository map instead of repeating broad searches. The pack is a navigation aid; exact source files still need to be read before changing behavior.
With Python 3 and Git installed, build a context pack for this repository itself:
git clone https://github.com/Stijnus/repository-context-engineer-skill.git
cd repository-context-engineer-skill
python3 scripts/build_context_pack_v3.py .
python3 scripts/build_context_pack_v3.py . --route-query "context pack generation"Open .claude/project-context/OVERVIEW.md for the repository map and .claude/project-context/QUERY_CONTEXT.md for ranked files. These commands generate local context files; they do not install a skill or modify your global agent settings. Follow the setup sections below to integrate the instructions with your agent.
This repository provides two instruction surfaces:
- Claude Code:
SKILL.md - Codex:
AGENTS.md
Both use the same generated project context pack under:
.claude/project-context/
That means Claude Code and Codex can share the same durable repo map instead of rediscovering the project from scratch on every task.
Most current approaches improve only one part of the problem:
- Repo packers like Repomix, GitIngest, and Code2Prompt are useful for one-shot prompt creation.
- Indexers/retrievers like Cursor and Sourcegraph improve search and retrieval.
- Claude Code memory (
CLAUDE.md, auto-memory, subagents) helps with instructions and recurring knowledge. - Codex repo guidance through
AGENTS.mdhelps with navigation, commands, and project conventions.
But those do not fully solve the missing middle layer:
a reusable, project-specific operating model that tells the agent what the repo is, how it is organized, where execution starts, which commands matter, and which folders own which responsibilities.
This package adds that middle layer by generating a project context pack inside the repository.
Instead of making the model rediscover the codebase on every task, generate and maintain lightweight project knowledge under:
.claude/project-context/
That folder becomes a reusable navigation layer for future tasks.
The pack gives the agent a working repo map:
- folder ownership and likely subsystem boundaries
- key docs, commands, configs, entrypoints, and important files
- likely files for a feature, route, service, or domain concept
It is not full line-by-line code understanding. The agent should still read exact files before editing behavior, and should say when an answer came from the pack, scoped search, or direct file reads.
SKILL.md— Claude Code versionAGENTS.md— Codex versionscripts/build_context_pack.py— stable V2 builderscripts/build_context_pack_v3.py— V3 graph-ranked builderscripts/update_skill.sh— macOS/Linux updater for Claude installs and Codex-target syncscripts/update_skill.ps1— Windows updater for Claude installs and Codex-target syncexamples/settings.snippets.jsonc— optional Claude Code hook exampleUSAGE.md— practical examples, commands, and expected output
Use V2 if you want the simpler, stable builder:
python scripts/build_context_pack.py .Use V3 if you want query-ranked context selection and lower search churn:
python scripts/build_context_pack_v3.py .V3 adds:
IMPORT_GRAPH.mdTOKEN_COUNTS.mdTASK_ROUTING.mdCHANGE_HOTSPOTS.mdSTALENESS.md- optional
QUERY_CONTEXT.md - optional
QUERY_RESULTS.json
python scripts/build_context_pack_v3.py .python scripts/build_context_pack_v3.py . --check-stalepython scripts/build_context_pack_v3.py . --route-query "billing flow"That last command is the important V3 addition. It writes a ranked file list for the query into:
.claude/project-context/QUERY_CONTEXT.md.claude/project-context/QUERY_RESULTS.json
The skill's files being on disk is not enough for Claude to actually use the pack. You also need a single global hook that tells Claude a pack exists. Without this hook Claude often ignores the pack and grep-bombs anyway.
Add this to ~/.claude/settings.json (global, one time):
{
"hooks": {
"UserPromptSubmit": [
{
"hooks": [
{
"type": "command",
"command": "test -f .claude/project-context/MANIFEST.json && echo 'REPO MAP AVAILABLE at .claude/project-context/. READ these files before any Read/Glob/Grep: OVERVIEW.md, AREAS.md, TASK_ROUTING.md. The pack already exists — do NOT rebuild it. The pack already ranks files for common tasks; consult it to pick the right source files, then read those exact files.' || true"
}
]
}
]
}
}How it behaves:
- Fires once per prompt.
- If the current repo has
.claude/project-context/MANIFEST.json, injects a one-line reminder for Claude. - If the repo has no pack, the hook is a silent no-op (zero overhead).
- Install once, works in every repo you later build a pack in.
This is the single most important install. The copy in examples/settings.snippets.jsonc includes both this hook and the optional auto-rebuild hook.
Install into a project like this:
.claude/
skills/
repository-context-engineer/
SKILL.md
README.md
scripts/
build_context_pack.py
build_context_pack_v3.py
update_skill.sh
update_skill.ps1
examples/
settings.snippets.jsonc
Then restart Claude Code.
You can also install it globally under:
~/.claude/skills/repository-context-engineer/
If you do that, adjust the script path in SKILL.md if needed.
Codex reads AGENTS.md, so place these files in the target repository:
AGENTS.md
scripts/
build_context_pack.py
build_context_pack_v3.py
update_skill.sh
update_skill.ps1
This repository now includes updater scripts for both macOS/Linux and Windows.
They can do two things:
- pull the latest changes from
origin/mainin a local checkout - sync the managed files into either a Claude Code skill install or a Codex target repository
By default the scripts create a file-level backup under:
.repository-context-engineer-backups/
inside the target before overwriting managed files.
If your installed skill directory is itself a git checkout of this repo, run:
bash scripts/update_skill.sh --pullIf you want to update a different Claude skill install from another local clone of this repo, run:
bash scripts/update_skill.sh --pull --target ~/.claude/skills/repository-context-engineerIf your installed skill directory is itself a git checkout of this repo, run:
powershell -ExecutionPolicy Bypass -File scripts/update_skill.ps1 -PullIf you want to update a different Claude skill install from another local clone of this repo, run:
powershell -ExecutionPolicy Bypass -File scripts/update_skill.ps1 -Pull -Target "$HOME\.claude\skills\repository-context-engineer"To refresh the vendored Codex files in a target repository from a local checkout of this repo:
bash scripts/update_skill.sh --pull --mode codex --target /path/to/target-repoOn Windows:
powershell -ExecutionPolicy Bypass -File scripts/update_skill.ps1 -Pull -Mode codex -Target "C:\path\to\target-repo"That updates only the managed Codex files:
AGENTS.mdscripts/build_context_pack.pyscripts/build_context_pack_v3.pyscripts/update_skill.shscripts/update_skill.ps1
You can still update manually with git pull and file copies, but the updater scripts are now the recommended path.
After any update, restart Claude Code or start a new Codex session so the new instructions are loaded.
This package does not add custom slash commands.
Use normal prompts such as:
- “Understand this repo before making changes.”
- “Build or refresh the repo context pack first.”
- “Map the codebase, then tell me which files likely own auth.”
- “Use the repo map first, then scoped search, then direct file reads.”
- “Run V3 query routing for billing and tell me the top files first.”
For Claude Code, SKILL.md tells Claude when to apply this flow.
For Codex, AGENTS.md tells Codex when to apply this flow.
After the package is used correctly, the agent should usually tell you:
- whether the context pack was generated, refreshed, reused, or is likely stale
- where the pack was written
- the top-level ownership map of the repo
- the key docs, commands, configs, and entrypoints
- the most likely files or folders for your task
- the confidence boundary: it has a working repo map, not full line-by-line memory
With V3 query routing, the agent should also be able to tell you:
- which files were ranked highest for the query
- why those files ranked highly
- which import neighbors or co-change partners should be checked next
- which heavy files should be delayed because they cost too many tokens
Do not expect this package to:
- instantly know exact file ownership without verification
- replace direct file reads before behavior edits
- behave like a full language server or compiler
- automatically commit generated
.claude/project-context/output unless you explicitly want that
Repo packers are usually snapshot exporters. They are excellent for sending a repo into an LLM once.
This package is instead a persistent repo operating layer:
- smaller than a full repo dump
- cheaper to load repeatedly
- targeted to agent navigation
- durable across tasks
- easy to keep up to date
- reusable by both Claude Code and Codex
Embeddings and semantic search help find relevant files, but they do not inherently explain:
- the startup path of the app
- which commands are canonical
- which top-level folders correspond to which responsibilities
- which files deserve to be read first
- which symbols form the public surface area of the project
This package makes those things explicit.
V3 is the first version that moves beyond a static repo map and toward task-specific context concentration.
The idea is:
- keep a reusable global repo map
- build graph and hotspot signals once
- route the current query to the smallest high-signal file set
- read exact files only after ranking them
That is the practical path to reducing repeated search loops and token waste.