code-context
Skill2 starsChanged 7 months agoMITView on GitHub
Generate and maintain a comprehensive code-context.md file that captures deep codebase understanding — models, routes, components, stores, architecture, data flows, and key patterns. Commands - init, update, uninstall.
- Deletes or force-pushes
1 other project uses a version of this.
Adopted by
Most recently taken up by
- eduardtomasek/agent-code-inteltheir own version, first seen Nov 8, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- eduardtomasek/agent-code-intel★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
The file
Show its rules and text
We split this skill into the rules it gives an agent
40 rules. About 0 are common, 20 are distinctive, and 20 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈20
Distinctive · estimate
This author's own choices. Worth a look.
20
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 34
Start by understanding the project at a high level:
- Very specific: line 36
Read the root package.json, Cargo.toml, go.mod, pyproject.toml, build.gradle, Package.swift, or equivalent to determine the tech stack
- Very specific: line 37
Check for monorepo indicators: lerna.json, pnpm-workspace.yaml, workspaces in package.json, Cargo.toml workspace members
- Very specific: line 38
Read any existing README.md, CLAUDE.md, ARCHITECTURE.md, or similar docs
- Very specific: line 39
If code-context.md already exists, read it to understand what was previously documented
- Distinctive: line 49
All database models/schemas with field names, types, indexes, relationships, and key methods
- Distinctive: line 50
All API routes with HTTP method, path, auth requirements, and purpose
- Very specific: line 82
Write the file to code-context.md in the project root with this structure:
- Very specific: line 123
If .gitignore does not exist at the project root, create it with a single line: code-context.md
- Very specific: line 124
If .gitignore exists, read it.
- Distinctive: line 128
Run git ls-files --error-unmatch code-context.md to check if it is tracked.
- Distinctive: line 129
If tracked (command exits 0), run git rm --cached code-context.md.
- Distinctive: line 130
If untracked (command exits non-zero), skip this step silently.
- Very specific: line 136
After generating code-context.md, ensure the project's CLAUDE.md has instructions for Claude to read and maintain it.
- Distinctive: line 138
Check if CLAUDE.md exists in the project root
- Distinctive: line 139
If it exists, read it and check if it already has a "Code Context" section
- Distinctive: line 140
If the section is missing, append it using the Edit tool
- Distinctive: line 141
If CLAUDE.md doesn't exist, create it using the Write tool
- Distinctive: line 173
Skip boilerplate: Don't document obvious framework conventions (React component lifecycle, Express middleware signature)
- Very specific: line 190
Update the existing code-context.md file to reflect recent structural changes.
- Very specific: line 194
Read the existing code-context.md
- Very specific: line 195
If the file doesn't exist, tell the user to run /code-context init first and stop
- Distinctive: line 197
If the user described what changed (arguments after "update"), focus on those areas
- Distinctive: line 198
If no description provided, check recent changes:
- Very specific: line 199
Run git diff --name-only <marker-hash>..HEAD to see files changed since last update (fall back to HEAD~5 if no marker)
- Very specific: line 200
Run git log --oneline <marker-hash>..HEAD to see commits since last update
- Distinctive: line 207
Read the current source files to understand what actually exists now
- Distinctive: line 209
Update the relevant sections using the Edit tool
- Distinctive: line 224
Update the "Last updated" date in the header to today's date
- Very specific: line 225
Update the <!-- code-context-marker: ...
- Distinctive: line 243
Remove code-context integration from the project while preserving the generated documentation.
- Distinctive: line 247
Read the project's CLAUDE.md
- Very specific: line 248
If it exists and contains a "Code Context" section, remove the entire section (from ## Code Context to the next ## heading or end of file)
- Distinctive: line 249
If removing the section leaves CLAUDE.md empty (or with only whitespace), delete the file entirely
- Distinctive: line 250
If CLAUDE.md doesn't exist or has no "Code Context" section, note that no changes were needed
- Very specific: line 257
If they run /code-context init again in the future, it will pick up from the existing code-context.md and update it rather than starting …
- Very specific: line 258
If they want to fully remove the skill itself, they can run /code-context global-uninstall
- Very specific: line 272
Check if ~/.claude/skills/code-context/ exists
- Very specific: line 273
If it exists, remove it: rm -rf ~/.claude/skills/code-context/
- Very specific: line 274
If it doesn't exist, check if the skill is installed per-project at .claude/skills/code-context/ and remove that instead
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Code Context Manager
You manage the code-context.md file for this project. This file serves as a persistent codebase understanding cache — it eliminates the need for every Claude session to re-explore the codebase from scratch.
User instructions
$ARGUMENTS
Command routing
Parse the first word of the user's arguments to determine the command:
init(or no arguments, or arguments that don't start withupdate/uninstall/global-uninstall) → Go to Init Commandupdate→ Go to Update Commanduninstall→ Go to Uninstall Commandglobal-uninstall→ Go to Global Uninstall Command
Init Command
Generate a comprehensive code-context.md from scratch. If a code-context.md already exists, read it first — preserve any sections that are still accurate and update/add sections that have changed or are missing. This allows re-initialization to build on prior work rather than starting from zero.
Step 1: Discover project structure
Start by understanding the project at a high level:
- Read the root
package.json,Cargo.toml,go.mod,pyproject.toml,build.gradle,Package.swift, or equivalent to determine the tech stack - Check for monorepo indicators:
lerna.json,pnpm-workspace.yaml,workspacesin package.json,Cargo.tomlworkspace members - Read any existing
README.md,CLAUDE.md,ARCHITECTURE.md, or similar docs - If
code-context.mdalready exists, read it to understand what was previously documented - Map the top-level directory structure
Step 2: Deep exploration
For each package/module in the project, explore thoroughly using the Agent tool with subagent_type: "Explore". Run multiple agents in parallel for independent packages.
For each package, capture:
Backend/API packages:
- All database models/schemas with field names, types, indexes, relationships, and key methods
- All API routes with HTTP method, path, auth requirements, and purpose
- Middleware chain and what each middleware does
- Service layer / business logic modules
- Configuration and environment variables with defaults
- Utility modules and what they export
Frontend packages:
- Navigation/routing structure with all routes
- Components with their purpose and key props
- State management (stores/reducers/contexts) with state shape and actions
- Custom hooks and what they return
- Utilities and helpers (especially platform-specific ones)
- Design system tokens (colors, typography, spacing)
Mobile / Native packages:
- Architecture pattern (MVVM, MVC, etc.)
- Module structure with responsibilities
- Networking layer and API client design
- Persistence strategy (local storage, database, keychain)
- Authentication flow and state machine
Infrastructure:
- CI/CD pipeline (jobs, triggers, branch rules, deploy targets)
- Docker setup
- Environment file hierarchy and key variables
- Build scripts and their purpose
- Auth provider configuration
Step 3: Generate code-context.md
Get the current git commit hash by running git rev-parse HEAD.
Write the file to code-context.md in the project root with this structure:
# [Project Name] Code Context
> **Purpose**: Persistent codebase understanding for Claude sessions. Eliminates cold-start exploration.
> **Last updated**: [today's date]
> **Update rule**: Update this file when making structural changes (new models, routes, components, stores, modules, config changes, or architectural shifts).
<!-- code-context-marker: [full git commit hash from git rev-parse HEAD] -->
---
## Project Overview
[What the project does, monorepo structure, tech stack summary, top-level directory tree]
## Package: [name] ([path])
[For each package, include ALL of the relevant sections from Step 2]
## Infrastructure
[CI/CD, Docker, env files, scripts, auth config]
## [Domain] Flow (End-to-End)
[Key flows like auth, data pipeline, etc. — how pieces connect across packages]
## Data Flow Summary
[ASCII diagram showing how data moves through the system]
## Key Patterns to Know
[Non-obvious conventions, composite IDs, platform-specific file patterns, transaction patterns, etc.]The <!-- code-context-marker: ... --> HTML comment is critical. It stores the git commit hash at the time of generation. This marker enables automatic change detection — at the start of future sessions, Claude compares this hash against the current HEAD to determine if the codebase has changed and the context needs updating.
Do not stage or commit code-context.md. The file is per-developer state and is kept out of version control (see Step 4 below). The skill must never run git add code-context.md or create a commit for it.
Step 4: Ensure code-context.md is gitignored
code-context.md is auto-generated per developer and every Claude session may rewrite it with slightly different content. Committing it produces repeated merge conflicts on shared branches, so the skill keeps it out of version control.
- Ensure
.gitignorelistscode-context.md:- If
.gitignoredoes not exist at the project root, create it with a single line:code-context.md - If
.gitignoreexists, read it. If it already containscode-context.mdas its own line (exact match, ignoring leading/trailing whitespace), do nothing. - Otherwise, append
code-context.mdon a new line. Preserve the existing file contents and trailing newline convention.
- If
- Untrack the file if it was previously committed:
- Run
git ls-files --error-unmatch code-context.mdto check if it is tracked. - If tracked (command exits 0), run
git rm --cached code-context.md. This removes it from the index without deleting the working-tree file. - If untracked (command exits non-zero), skip this step silently.
- Run
- If
git rm --cachedran, warn the user that they must commit the untracking so other team members stop pulling the file: "I untrackedcode-context.mdfrom git. Commit this change (git add .gitignore && git commit -m 'gitignore code-context.md') so other team members stop receiving the file on pull."
Step 5: Set up CLAUDE.md for auto-maintenance
After generating code-context.md, ensure the project's CLAUDE.md has instructions for Claude to read and maintain it. This is what makes the system self-sustaining.
- Check if
CLAUDE.mdexists in the project root - If it exists, read it and check if it already has a "Code Context" section
- If the section is missing, append it using the Edit tool
- If
CLAUDE.mddoesn't exist, create it using the Write tool
The section to add (copy exactly):
## Code Context
At the start of every session:
1. Read `code-context.md` in the project root if it exists.
2. Check the `<!-- code-context-marker: <hash> -->` comment in the file against the output of `git rev-parse HEAD`.
3. If the hashes differ (codebase has changed since last context update), automatically run the equivalent of `/code-context update` — read recent changes via `git diff <marker-hash>..HEAD --name-only` and `git log <marker-hash>..HEAD --oneline`, then update the affected sections in `code-context.md` and set the marker to the current HEAD hash.
This file contains deep codebase understanding and eliminates exploratory warm-up.
When you make changes that affect anything documented in `code-context.md`, update it before
completing the task and set the marker to the current HEAD hash. This includes structural changes
(new/removed models, routes, components, stores, modules, config) AND behavioral changes
(implementing a deferred feature, changing a status, adding interactions, modifying flows).
If in doubt, scan `code-context.md` for mentions of the area you changed — stale entries
defeat the purpose of the file.This step is not optional. Without CLAUDE.md setup, the context file becomes a one-time snapshot that goes stale. The CLAUDE.md instruction is what closes the loop.
Quality guidelines
- Be deep: List individual model fields, route paths, component props — not just file names
- Be precise: Include actual values (port numbers, default configs, thresholds) not vague descriptions
- Be relational: Show how pieces connect (which store calls which API, which model relates to which)
- Be practical: Include the patterns someone needs to know to work in this codebase safely
- Use tables: For models, routes, config vars — they're scannable and dense
- Include types/enums: State shapes, status enums, error types — these prevent bugs
- Skip boilerplate: Don't document obvious framework conventions (React component lifecycle, Express middleware signature)
After init
Tell the user:
code-context.mdhas been generated at the project rootcode-context.mdhas been added to.gitignore(and untracked from git if it was previously committed — flag this separately and remind them to commit the.gitignorechange)CLAUDE.mdhas been set up (or updated) to auto-read and auto-maintain the context file- The context file includes a git hash marker for automatic change detection
- From now on, every Claude session will check for codebase changes and auto-update if needed
- They can run
/code-context updatemanually after large refactors - Suggest they review the file and flag any inaccuracies or missing areas
Update Command
Update the existing code-context.md file to reflect recent structural changes.
Step 1: Understand current state
- Read the existing
code-context.md - If the file doesn't exist, tell the user to run
/code-context initfirst and stop - Extract the current marker hash from
<!-- code-context-marker: ... --> - If the user described what changed (arguments after "update"), focus on those areas
- If no description provided, check recent changes:
- Run
git diff --name-only <marker-hash>..HEADto see files changed since last update (fall back toHEAD~5if no marker) - Run
git log --oneline <marker-hash>..HEADto see commits since last update - Identify which sections of code-context.md are affected
- Run
Step 2: Verify and update affected sections
For each affected area:
- Read the current source files to understand what actually exists now
- Compare with what
code-context.mdcurrently says - Update the relevant sections using the Edit tool
Focus on:
- New models/schemas → add to the models table with full field details
- Removed models → remove from the table
- New routes/endpoints → add to the routes table
- Changed routes → update method, path, auth, or purpose
- New components/stores/hooks → add with purpose and key details
- Removed code → remove from the document
- Config changes → update environment variables, ports, defaults
- New packages/modules → add a new package section
- Architecture changes → update patterns, flows, or overview
Step 3: Update metadata
- Update the "Last updated" date in the header to today's date
- Update the
<!-- code-context-marker: ... -->to the currentgit rev-parse HEADhash
Update guidelines
- Only change what's affected — don't rewrite the entire file
- Match existing style — use the same table format, heading structure, and level of detail
- Verify before writing — read the actual source files, don't guess from commit messages alone
- Remove stale info — if something was deleted, remove it from the doc rather than marking it as removed
- Keep it accurate — if you're unsure about a change, read the source to confirm
After update
Tell the user what sections were updated and why. Mention the marker has been updated to the current HEAD.
Uninstall Command
Remove code-context integration from the project while preserving the generated documentation.
Step 1: Remove CLAUDE.md references
- Read the project's
CLAUDE.md - If it exists and contains a "Code Context" section, remove the entire section (from
## Code Contextto the next##heading or end of file) - If removing the section leaves
CLAUDE.mdempty (or with only whitespace), delete the file entirely - If
CLAUDE.mddoesn't exist or has no "Code Context" section, note that no changes were needed
Step 2: Confirm to user
Tell the user:
- The "Code Context" section has been removed from
CLAUDE.md— Claude will no longer auto-read or auto-update the context file code-context.mdhas been left in place — they can remove it manually withrm code-context.mdif they wish- If they run
/code-context initagain in the future, it will pick up from the existingcode-context.mdand update it rather than starting from scratch, so keeping it around is safe - If they want to fully remove the skill itself, they can run
/code-context global-uninstall
Global Uninstall Command
Completely remove the code-context skill from the system. This performs the project-level uninstall AND removes the skill files from the global Claude configuration.
Step 1: Run project-level uninstall
First, perform the same steps as the Uninstall Command — remove the "Code Context" section from the current project's CLAUDE.md.
Step 2: Remove skill files
- Check if
~/.claude/skills/code-context/exists - If it exists, remove it:
rm -rf ~/.claude/skills/code-context/ - If it doesn't exist, check if the skill is installed per-project at
.claude/skills/code-context/and remove that instead
Step 3: Confirm to user
Tell the user:
- The "Code Context" section has been removed from this project's
CLAUDE.md - The skill files have been removed from
~/.claude/skills/code-context/(or.claude/skills/code-context/) - The
/code-contextcommand will no longer be available in new sessions code-context.mdhas been left in place in the project — they can remove it manually withrm code-context.mdif they wish- To reinstall later, they can follow the install instructions at https://github.com/leverj/claude-code-context
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

