agentleFS
SubhoMSubhoM/persistent-agent-context/SKILL.md

repo-memory

Skill0 starsChanged 4 months agoMITView on GitHub

Establishes and maintains a persistent project knowledge base in the repo's /docs folder so any coding assistant — Claude Code, Copilot, Cursor, or similar — can understand the codebase, avoid repeating past investigations, and minimize token usage across sessions. Use this skill at the start of every development session to check for and read existing /docs, whenever no /docs knowledge base exists yet and one should be created, immediately after a significant discovery, bug root-cause, or architectural decision, and before completing any task to keep the documentation current. Also trigger when explicitly asked to "document this repo," "update the project docs," or "check the knowledge base.

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    1. Jeff-Tian/agent-skills★ 1same 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.

  • In this repository2 other files it gives its agents.

The file

Show its rules and text

We split this skill into the rules it gives an agent

15 rules. About 0 are common, 9 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈9

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Check whether /docs exists.

    line 16
  2. Distinctive:

    If it does not exist: create it and generate the full documentation structure below.

    line 17
  3. Very specific:

    If it exists: read docs/agent-context.md first, then the other files as relevant to the current task.

    line 19
  4. Distinctive:

    Use the documentation as project memory for the rest of the session — don't re-derive what's already documented.

    line 22
  5. Distinctive:

    Update documentation continuously as new information is discovered — immediately after a major finding, not batched at the end of session.

    line 74
  6. Distinctive:

    Remove information that has since been proven incorrect.

    line 79
  7. Very specific:

    Add a Last Updated timestamp to every file you touch.

    line 85
  8. Distinctive:

    Before completing any task:

    line 87
  9. Very specific:

    Before writing or updating any file under /docs, scan the draft for anything that shouldn't be committed to version control: API keys, …

    line 95
  10. Distinctive:

    Use short, searchable sections and bullet points wherever possible.

    line 105
  11. Distinctive:

    Avoid duplicating information across files — link between them instead.

    line 107
  12. Distinctive:

    Keep documentation concise and optimized for AI consumption, not prose written for a human skim-reader.

    line 110
  13. Distinctive:

    Write documentation as plain, tool-agnostic markdown — this file is read by whatever assistant opens the repo next, not one specific tool.

    line 132
  14. Very specific:

    If the repo already has a CONTRIBUTING.md or architecture doc, don't duplicate it — link to it from the relevant /docs file instead.

    line 134
  15. Very specific:

    Keep it a one-line @AGENTS.md import (or a symlink) so Claude Code follows the same instructions without a second copy to maintain.

    line 150

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Repo Memory

Maintains a persistent source of truth for a project in its /docs folder, so future sessions — by any coding assistant, not just one tool — can understand the codebase, skip re-investigating what's already known, and avoid repeating past mistakes. This is project memory that lives in the repo itself, not in any single assistant's session.

Startup process (run this first, every session)

  1. Check whether /docs exists.
  2. If it does not exist: create it and generate the full documentation structure below.
  3. If it exists: read docs/agent-context.md first, then the other files as relevant to the current task. Do this before analyzing or modifying any code.
  4. Use the documentation as project memory for the rest of the session — don't re-derive what's already documented.

Documentation structure

docs/agent-context.md — primary context file, read first

  • Project summary and business purpose
  • Technology stack
  • Architecture snapshot
  • Important constraints
  • Coding standards
  • Recurring pitfalls
  • Active workstreams
  • Onboarding notes for future sessions

docs/architecture.md

  • System architecture and application flow
  • Major modules and component relationships
  • Integrations
  • Deployment / build information
  • Infrastructure observations

docs/code-patterns.md

  • Coding conventions
  • Reusable patterns and common implementation approaches
  • State management patterns
  • Data access patterns
  • Testing patterns
  • Examples and references

docs/findings.md

  • Repository discoveries
  • Architectural findings
  • Undocumented behavior
  • Important file locations
  • Framework-specific observations
  • Troubleshooting notes

docs/issues-and-decisions.md

  • Bugs identified, with root causes and fixes implemented
  • Design decisions and tradeoffs
  • Lessons learned

docs/future-work.md

  • Technical debt
  • Open questions
  • Known limitations
  • Future improvements
  • Pending investigations

Maintenance rules (apply throughout the session)

  • Update documentation continuously as new information is discovered — immediately after a major finding, not batched at the end of session.
  • Prefer updating existing sections over creating duplicates. This is what keeps the knowledge base from becoming a stale, ever-growing log — edit in place.
  • Remove information that has since been proven incorrect; don't leave it contradicted by a newer note.
  • Mark uncertain findings explicitly as Needs Verification rather than stating them as fact.
  • For every significant discovery, record: what was found, the evidence, relevant file paths, the impact, and recommended actions if applicable.
  • Add a Last Updated timestamp to every file you touch.

Before completing any task:

  • Review the documentation for accuracy against what you now know.
  • Update affected sections.
  • Confirm the knowledge base reflects the current understanding of the repository — not a stale snapshot from earlier in the session.

Redaction pass (required before every write)

Before writing or updating any file under /docs, scan the draft for anything that shouldn't be committed to version control: API keys, tokens, credentials, connection strings, customer or employee PII, or internal-only business logic that shouldn't be broadly readable. Strip or generalize matches — describe the shape of the issue rather than including literal secrets.

Documentation guidelines

  • Record facts, not assumptions.
  • Use short, searchable sections and bullet points wherever possible.
  • Include file paths and code references.
  • Avoid duplicating information across files — link between them instead.
  • Preserve important historical decisions rather than deleting them when superseded; note that they were superseded and why.
  • Keep documentation concise and optimized for AI consumption, not prose written for a human skim-reader.

Success criteria

A brand-new session should be able to read docs/agent-context.md alone and understand at least 80% of the project's architecture, conventions, constraints, known issues, and current development direction — without re-investigating the codebase.

Why this matters (token economics)

Re-discovering context from scratch each session — semantic search, reading components, trial-and-error discussion — commonly runs 45,000–200,000 tokens per issue. Reading a maintained knowledge base first typically drops that to 2,000–15,000 tokens for the same issue: roughly a 70–90% reduction, compounding across every developer and every session. See references/token-efficiency-rationale.md for the full breakdown and worked example this figure is based on.

Notes

  • Write documentation as plain, tool-agnostic markdown — this file is read by whatever assistant opens the repo next, not one specific tool.
  • If the repo already has a CONTRIBUTING.md or architecture doc, don't duplicate it — link to it from the relevant /docs file instead.

Cross-tool setup (Claude Code, Copilot, Codex, etc.)

This SKILL.md packages the workflow — when to run it and how to maintain /docs. It doesn't by itself make Codex or Copilot pick it up automatically, since those tools don't discover Claude Skills.

For actual cross-tool auto-loading at session start, pair this skill with:

  • AGENTS.md at the repo root — read natively by Codex CLI, GitHub Copilot, Cursor, Windsurf, and most other agents. This should contain the condensed startup process and /docs pointer (see this skill's companion AGENTS.md).
  • CLAUDE.md — Claude Code reads this, not AGENTS.md, natively. Keep it a one-line @AGENTS.md import (or a symlink) so Claude Code follows the same instructions without a second copy to maintain.

In short: /docs/* is the actual knowledge base content (fully tool-agnostic); AGENTS.md + CLAUDE.md are the thin bootstrap files that get each tool to read it; this SKILL.md is the richer, triggerable version of the same workflow for tools that support Agent Skills.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.