prime-context
Skill1 starsChanged 5 days agoMITView on GitHub
Manage thin AGENTS.md files, load context by area, capture durable learnings, and audit project context. Use setup shared to share rules and curated memory across Claude Code, Codex, and OpenCode. Use compaction to inspect or configure native session summarization.
2 other projects use a version of this.
Adopted by
Most recently taken up by
- pablof7z/skillstheir own version, first seen Jul 13, 2026
- HermeticOrmus/prime-context-skillstheir own version, first seen May 25, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- pablof7z/skills★ 1same name
- HermeticOrmus/prime-context-skills★ 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
28 rules. About 0 are common, 13 are distinctive, and 15 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈13
Distinctive · estimate
This author's own choices. Worth a look.
15
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 26
Use its global memory/MEMORY.md for cross-project notes.
- Very specific: line 30
Run the CLI with Python 3.8 or newer.
- Very specific: line 43
Use migrate --map=CLAUDE-FOLDER=PATH to bind an unmapped folder explicitly.
- Distinctive: line 45
Add new entries as pointers, one per memory file.
- Very specific: line 69
Run sync --check to find newly written sensitive shared notes or quarantine --apply to mark them Claude-only with backups.
- Distinctive: line 74
Keep new memory content in linked notes so the index stays cheap to scan.
- Distinctive: line 113
If the check fails, rewrite the draft without the sensitive value and check again.
- Very specific: line 120
Never touch AGENTS.md itself (rules there are managed via improve).
- Very specific: line 129
If shared context is configured, consult the global index and run shared_sync.py resolve for the project index.
- Distinctive: line 140
If the task at hand clearly touches several areas, read the relevant files in parallel.
- Distinctive: line 170
Read the entire AGENTS.md (or CLAUDE.md) at the CWD.
- Very specific: line 174
Ensure CLAUDE.md points at AGENTS.md (see symlink/fallback rules in setup).
- Distinctive: line 214
Keep total imperative instructions in AGENTS.md well under 150 — merge similar rules, push details into context files.
- Distinctive: line 219
Never invent content — only reorganize what already exists in the original file.
- Very specific: line 222
Idempotent re-runs: if .claude/context/ already has files, merge new content into the matching area file section by section — never …
- Distinctive: line 233
Follow the shared setup procedure.
- Distinctive: line 246
Use the CWD as project root (ask if ambiguous).
- Distinctive: line 247
Ask: "Describe the project in 1-2 lines (what it does, stack, for whom)."
- Distinctive: line 248
Ask: "What are the main work areas?
- Very specific: line 250
Create .claude/context/<area>.md for each area with the header # Context: <Area> and a <!-- Fill in as the project evolves --> comment.
- Distinctive: line 252
Create AGENTS.md from the thin template (routing table pointing at the created areas).
- Very specific: line 258
Create <Claude config>/projects/<folder>/memory/MEMORY.md containing the format spec header:
- Very specific: line 265
If AGENTS.md already exists → offer improve instead of overwriting.
- Very specific: line 266
If CLAUDE.md is already a symlink or an @AGENTS.md import → leave it alone.
- Distinctive: line 267
If CLAUDE.md is a regular file with real content → ask before replacing.
- Very specific: line 276
Use Compaction. Bare compaction means status and is read-only.
- Very specific: line 286
Run shared_sync.py doctor in addition to the project checks below.
- Very specific: line 310
Never modify context files during load — read only.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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
Prime Context
Manage project context efficiently — never load everything at once.
Core philosophy
AGENTS.md must be thin. It is loaded in EVERY session — every line costs tokens in every conversation.
Detailed content lives in .claude/context/<area>.md and is read only when the task requires it.
AGENTS.md contains only: overview (2 lines), routing table, non-negotiable rules, PR checklist.
This skill covers both directions: <area> is the read path (assemble the right
context into a session); the bare call is the write path (learn — persist this
session's learnings into those same files, so the next session starts smarter).
Memory location
Shared context is configured when the marker .prime-context-shared contains
format=1 in $PRIME_CONTEXT_SHARED_HOME (default ~/.config/agent-instructions).
Use its global memory/MEMORY.md for cross-project notes. Use shared_sync.py resolve
for the project index. For unregistered projects, use the existing Claude project
memory location below.
Run the CLI with Python 3.8 or newer. With the Claude Code plugin, the script is
${CLAUDE_PLUGIN_ROOT}/scripts/shared_sync.py. When only the skill folder is
installed, including in Codex or OpenCode, use <skill dir>/scripts/shared_sync.py.
See the shared setup contract.
MEMORY.md format (specification)
Claude's local MEMORY.md lives at
<Claude config>/projects/<folder>/memory/MEMORY.md. The config root is
$CLAUDE_CONFIG_DIR or ~/.claude. Claude replaces every character outside
[A-Za-z0-9] in the absolute project path with -. Migration considers the first
cwd in each transcript when it still exists and reproduces the folder name.
The home folder supplies global memory by default, even without transcripts.
Use migrate --map=CLAUDE-FOLDER=PATH to bind an unmapped folder explicitly.
Add new entries as pointers, one per memory file. Migrated indexes can also contain prose preserved from the original indexes:
- [Short title](filename.md) — one-line hook describing when this mattersEach referenced memory file is self-contained Markdown. Use this frontmatter for shared notes:
---
name: <slug>
description: <one line>
metadata:
type: user|feedback|project|reference
share: all|claude-only
---An absent metadata.share means all. Other harnesses must skip notes marked
claude-only. Doctor flags legacy top-level type as LOW. In Claude Code the
plugin runs an incremental, time-bounded quarantine at SessionStart and resumes
unfinished work on the next run. Quarantine backups stay in .state/backups/.
Run sync --check to find
newly written sensitive shared notes or quarantine --apply to mark them
Claude-only with backups. Remove sensitive values from credentials and attachments
at their source.
- Keep new memory content in linked notes so the index stays cheap to scan.
- Dead pointers (file missing) are flagged by
doctorand duringload. - Memory files are point-in-time — warn when the newest is older than 7 days.
Command: learn (default — no argument, or the literal word learn)
Capture what this session taught into the context files. Claude Code already loads AGENTS.md/CLAUDE.md at session start — re-reading it adds nothing. The bare call's job is the opposite direction: write the session's learnings down so the next session starts smarter.
Flow:
- Review the current conversation for durable learnings: user corrections, decisions made, pitfalls hit, commands/configs discovered, gotchas that cost time. Ignore anything only relevant to this one task.
- Route each learning:
- Area-specific → append to the matching
.claude/context/<area>.md(fuzzy-match as inload). No matching area → propose creating one (file + routing-table row). - Personal learning → a note and a pointer in the selected private memory index. Use the shared global index for a confirmed cross-project preference, the shared project index for a project-specific note, or the existing Claude project memory when shared context is not configured.
- Area-specific → append to the matching
- Check for contradicted memories, not just new ones. For every memory file touched
by this session's topic (same file, or linked via
[[name]]from one that is), check whether a specific claim it makes — a host, path, account owner, version, "current state of X" — is contradicted by evidence seen this session (a file read, a command result, a user statement). A contradicted claim is not an append target: rewrite the memory (current facts first, superseded history below, old claim struck through or moved to a clearly marked "historical" section) rather than tacking an "update" paragraph onto unchanged prose. If the whole file's premise died (e.g. the resource it describes no longer exists or isn't the user's anymore), delete the file and its MEMORY.md pointer line instead of leaving a corpse — don't invent this without evidence: only rewrite/delete what this session actually contradicted, leave everything else untouched. - For learnings that don't contradict anything, check the target file — skip anything already recorded; update in place if the learning supersedes an existing line.
- In shared mode, stage the note privately and run
shared_sync.py check-note FILE. If the check fails, rewrite the draft without the sensitive value and check again. When recording a credential, point to its storage location. Once the check passes, publish the note and add a new pointer withshared_sync.py append-index INDEXFILE LINE --apply. Concurrent appends are serialized and commit atomically without creating a backup for each pointer. - Report one bullet per learning written or memory rewritten/deleted, with its
destination file. Nothing durable in the session → say
learn: nothing newand stop. Never touch AGENTS.md itself (rules there are managed viaimprove).
Command: load (an area name as argument)
Load one area's context on demand.
Flow:
- If shared context is configured, consult the global index and run
shared_sync.py resolvefor the project index. Load only notes relevant to the area. If resolve exits 4 or 5, use the legacy Claude project index if it exists. Outside Claude Code, inspect each note's frontmatter before loading its body and skip notes withmetadata.share: claude-only. Disclose broken pointers in Verification. - Resolve the area argument:
- Exact filename match on
.claude/context/<area>.mdwins. - Otherwise case-insensitive substring match against files in
.claude/context/(e.g.filamentmatchesphp-filament.md). - Zero or multiple matches → list the available areas and ask which one.
- Exact filename match on
- If the task at hand clearly touches several areas, read the relevant files in parallel.
Output format:
## Context loaded — <area>
### Relevant now
<3-5 critical points for this session>
### Known pitfalls
<Applicable learnings from memory>
### Quick reference
<Most-used commands or configs>
### Verification
<Files actually read, one per line, with approximate size — so drift is visible>The Verification block is mandatory: list each file that was actually read and its approximate line count. If a routed file was missing, say so explicitly instead of omitting it.
Command: improve
Goal: take a bloated AGENTS.md (any project) and refactor it into the thin + context-files architecture.
Flow:
- Read the entire
AGENTS.md(orCLAUDE.md) at the CWD. - Identify natural groupings by area (e.g. Filament, API, DB, prod, multi-tenancy).
- For each area, create
.claude/context/<area>.mdwith that area's detailed content. - Rewrite
AGENTS.mdfollowing the thin template below. - Ensure
CLAUDE.mdpoints atAGENTS.md(see symlink/fallback rules insetup).
Thin AGENTS.md template:
# <Project Name>
<1-2 line description: what it does, main stack>
## Load context before working
Before starting any task, read the matching context file:
| Area | File |
|------|------|
| <area 1> | `.claude/context/<area1>.md` |
| <area 2> | `.claude/context/<area2>.md` |
If a task touches multiple areas, read the relevant files in parallel.
## Non-negotiable rules (always apply)
<Only rules that apply to EVERY task — max 8 concise bullets>
## Checklist before opening a PR
<Full checklist — always worth keeping here>
## Essential commands
<Only the most-used day-to-day commands>
<Any tool/MCP auto-managed block goes at the end, untouched>Quality rubric — apply while restructuring (aligned with documented CLAUDE.md best practices):
- Target the thin AGENTS.md at ≤ ~2.5k tokens (~100–150 lines); treat 4k as a hard ceiling.
- Static content first, dynamic last (cache-friendly ordering): overview, routing table, rules and checklist are static; anything that changes often (learnings, gotchas) belongs in context files, not in AGENTS.md.
- Keep total imperative instructions in AGENTS.md well under 150 — merge similar rules, push details into context files.
- Each context file gets the header
# Context: <Area>and must be self-contained.
Improve rules:
- Never invent content — only reorganize what already exists in the original file.
- Auto-managed blocks (
<laravel-boost-guidelines>,## graphify, etc.) go at the end of AGENTS.md, byte-for-byte intact. - Idempotent re-runs: if
.claude/context/already has files, merge new content into the matching area file section by section — never blind-overwrite; when the same topic exists in both with conflicting content, keep both versions side by side under a<!-- MERGE: review -->comment and tell the user. Runningimproveon an already-thin AGENTS.md is a no-op that reports "already thin" with the current line/token count. - Afterwards, report: AGENTS.md line count before and after, and the list of files created/updated.
Command: setup shared
Follow the shared setup procedure. Initialize the
store, review the migration plan, close Claude Code sessions before applying it,
generate the entrypoints, and run doctor.
Match the complete setup shared argument before the standalone setup command.
Command: setup
Goal: configure the context structure from scratch in a new project.
Flow:
- Use the CWD as project root (ask if ambiguous).
- Ask: "Describe the project in 1-2 lines (what it does, stack, for whom)."
- Ask: "What are the main work areas? (e.g. API, database, infra, frontend)" — suggest candidates based on the detected stack.
- Create
.claude/context/<area>.mdfor each area with the header# Context: <Area>and a<!-- Fill in as the project evolves -->comment. - Create
AGENTS.mdfrom the thin template (routing table pointing at the created areas). - Make
CLAUDE.mdresolve toAGENTS.md:- Preferred: symlink
CLAUDE.md → AGENTS.md. - Fallback (Windows,
core.symlinks=false, or any environment where symlinks fail): create a regularCLAUDE.mdcontaining only the import line@AGENTS.md— Claude Code's import syntax gives the same single-source-of-truth effect without a symlink.
- Preferred: symlink
- Create
<Claude config>/projects/<folder>/memory/MEMORY.mdcontaining the format spec header:# Memory index — one pointer per line, content lives in the linked files <!-- - [Short title](filename.md) — one-line hook -->
Setup rules:
- If
AGENTS.mdalready exists → offerimproveinstead of overwriting. - If
CLAUDE.mdis already a symlink or an@AGENTS.mdimport → leave it alone. - If
CLAUDE.mdis a regular file with real content → ask before replacing.
After setup, report: files created, how to fill context files as the project evolves,
and how to add learnings (a file in memory/ + a pointer line in MEMORY.md).
Command: compaction [status|enable|disable]
Use Compaction. Bare compaction means status and is
read-only. enable and disable apply to the active harness unless the user
names another one. Resolve the complete command before matching an area name.
Command: doctor
Goal: audit the context structure for drift. Read-only — reports, never fixes silently.
Run shared_sync.py doctor in addition to the project checks below. Pass
--claude-home DIR if auditing a different Claude configuration.
Checks:
- Dangling routes — entries in the AGENTS.md routing table whose
.claude/context/<area>.mdfile does not exist. - Orphan context files — files in
.claude/context/missing from the routing table. - Dead memory pointers — lines in the selected MEMORY.md referencing files that don't exist. In shared mode, also check entrypoints and the project index mapping.
- Stale memory — newest memory file older than 7 days.
- AGENTS.md weight — line count and approximate token estimate (~4 chars/token); flag over ~150 lines / 2.5k tokens, hard-flag over 4k tokens.
- Ordering — dynamic-looking sections (learnings, gotchas, recent changes) sitting above static sections in AGENTS.md (cache-hostile).
- CLAUDE.md linkage — CLAUDE.md is neither a symlink to AGENTS.md nor an
@AGENTS.mdimport (drift risk: two diverging sources of truth).
Output: one line per finding with severity (HIGH/MED/LOW) and the specific fix.
End with doctor: N findings or doctor: clean. Offer to apply fixes only after reporting.
General rules
- Never modify context files during
load— read only. Writes happen only vialearn,improve,setup, andsetup shared. Change compaction settings only through the explicitcompaction enableorcompaction disableworkflow. - Blocks auto-managed by MCP servers are untouchable.
- Memory files are point-in-time — warn when > 7 days without updates.
- Unrecognized mode: list available commands (
learn,<area>,improve,setup,setup shared,compaction,doctor) and ask.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
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.

