项目内存用于编码代理和人类:代码库作为 Markdown 的背后的推理
Keep a Changelog records what changed. Keep the Why preserves why it changed.
Keep the Why is the why layer of repo-native project memory: your repository already holds what the project is, how it works and what changed; this is the agent skill, and the file convention it maintains, that preserve the one thing it was missing — the reasoning behind a codebase — architecture decisions, rejected alternatives, workarounds, incident learnings, operational constraints that the code alone can't explain — in the repo. That memory is plain Markdown in context/, committed with the code, so Git already provides the storage, the history and the distribution: it travels with every clone, branch and fork, and a pull request shows the reasoning diff beside the code diff. It captures that reasoning as a byproduct of working with your agent, so every later session can use it. Your agent, and every other agent that works in the repository, understands not just the code but everything around it: why it is the way it is, what was tried and rejected, which constraints the source doesn't show. So does the next person. Onboarding gets faster, legacy projects become tractable again. It works continuously as you develop, where the reasoning comes for free.
It pays off most where re-debated decisions, forgotten workarounds and departed knowledge cost the most: maintainers and teams running coding agents on long-lived codebases. Starting on an existing repository works too, within limits — history, issues and code give back only part of the why, a maintainer has to fill in the rest, and that takes real effort. It is never too late to begin, though.
The payoff, made concrete: a new hire, or an AI agent that's never touched the codebase before, doesn't have to track down whoever wrote the original code — and doesn't just repeat what was already tried and rejected. The same context makes changes safer across the board — no more guessing whether an odd piece of code is a Chesterton's Fence worth keeping or just cruft nobody got around to removing — turning a legacy project back into something tractable instead of a black box only one person ever understood. "Ask Bob" stops being the fallback.
Documentation is normally extra work that happens after the code is done — reload the reasoning from memory, write it down again, file it somewhere else: a wiki, an ADR, a PR description nobody reopens. That's exactly why it so often doesn't happen. When an agent is already how you work — deciding, weighing trade-offs, explaining itself in the same conversation that produces the change — the reasoning shows up for free, as a byproduct of that conversation, not separate effort. Keep the Why's actual job is narrower than it sounds: don't let that reasoning get thrown away.
Tested with: Claude Code, opencode, Pi, Hermes, and more — see the full eval suite and the agent × model matrix for what's actually been run against what, and how.
Website: https://keepthewhy.com · llms.txt for AI agents/assistants looking up this project
Important project knowledge gets created in conversation — with a teammate, or with an AI coding agent — and then evaporates once the conversation ends. The code shows what was built. It rarely shows why. Tests preserve expected behavior; they don't preserve the reasoning behind it — a project can be fully tested and still hard to maintain because nobody can explain why any of it works the way it does. Missing reasoning costs you in four concrete ways:
Keep the Why's agent skill is SKILL.md-based — an open, cross-agent format (Claude Code, Codex CLI, Gemini CLI, Cursor, and others). It operates in four modes:
First activation in a project runs a short one-time setup instead of guessing at defaults — where the why-knowledge should live, how to start, proactive or explicit-only capture, how much confirmation is needed before something gets written, whether to actively ask for a related issue or ticket, whether to periodically check for skill updates or context/ staleness, whether to wire the structural linter into the project's CI, whether the agent should run that linter locally on what it writes (installing it from PyPI — the default — or asking first), and how the skill gets loaded in future sessions (by default the project asks, through a section in its entry-point file and a hook where the platform has one). The defaults are the fully integrated setup, one word away; each wizard is one list with the defaults filled in, and whoever wants less picks less. See references/setup.md.
Set up the way the wizard proposes, the skill is loaded in every session — measured, and in my own daily use. Loading is the agent's job, and the skill hands it over explicitly: a skill package is instructions; no agent tool, and nothing in the open Agent Skills spec, gives a skill a way to load itself at session start. So the setup wizard asks how this project wants the skill loaded and has the agent set up what its own platform offers. references/autostart.md defines three start paths — every session machine-wide, the project asks (a hook, or a "Keep the Why" section in the project's AGENTS.md), or only when a developer asks — and lists per agent tool what is verified how. With a start path in place, loading does not depend on the conversation happening to match the skill's description — it is not a sometimes thing: Claude Code loads it in every measured session, by the hook (10/10 on the sessions that had gone 0/10 without one) and by the entry-point section (3/3, against 0/3 without it); Codex CLI, opencode and Cline load it by the section (3/3 each, against 0 or 1 of 3 without it); Hermes Agent by a live run. A tool that is not listed has not been measured, not failed — a pull request with a verified example is welcome any time; for anything else, open a new issue.
Because it's just Markdown in the repo, a context/ update ships in the same commit or PR as the code change it explains — reviewed the same way, versioned the same way, no separate system to trust or keep in sync.
The skill's behavior is exercised by a suite of eval cases, executed for real — a fixture project per case, a fresh agent session, LLM-judged verdicts. Full-suite numbers (case count, results, an honest failure analysis, the stated caveats) are tracked against Claude Code specifically: Evals. Which other agents and models the skill has actually been run against, and how: agent & model matrix. What changed per release, including what the evals found: CHANGELOG; open problems and ideas, one issue each: issues. One controlled experiment on the core claim — twenty fresh sessions asked to simplify a retry wrapper, ten with the rejected alternative recorded in context/ and ten without: What happens when a coding agent forgets why a change was rejected?, with every transcript, diff and grade under experiments/rejected-change/.
Where the captured knowledge actually lives, and how it relates to everything else a project already has, is one coherent picture — see "Where this fits" below.
main is active development, not guaranteed release-ready — pin to latest instead of tracking it directly (moved automatically by CI to the newest release; use an exact tag instead for full reproducibility).
Recommended — skills CLI (via npx, needs Node.js — npx ships with it, nothing extra to install):
npx skills add https://github.com/oliver-zehentleitner/keep-the-why/tree/latest/skills/keep-the-whyPrompts you to select one of 70+ supported agents (Claude Code, Codex, OpenCode, and more) and choose whether to install the skill at project or personal scope, then symlinks or copies the skill package in. Also listed on skills.sh. Start a new session afterward so the skill is picked up, then tell your agent something like "initialize Keep the Why in this project" — a Skill activates when something in the conversation matches it, not automatically on session start, and setup on a brand-new project only runs from a request like this one, never from an unrelated question the skill's description happens to match. This is only needed once: setup creates a .keep-the-why file at the project root, checked directly by this skill at the start of every later session — later sessions pick the project back up without needing to be told again.
Other install methods — GitHub CLI, manual clone, agent-specific paths
Also recommended — GitHub CLI (gh v2.90.0+):
gh skill install oliver-zehentleitner/keep-the-why keep-the-why@latestPrompts for which agent and scope (project or personal) to install for. This installs just the skill package (skills/keep-the-why/), not the whole repo — no docs/, mkdocs config, or CI files end up in your project.
Also installable via asm (agent-skill-manager):
asm install github:oliver-zehentleitner/keep-the-why#latest:skills/keep-the-why --tool Replace `` with your agent (claude, codex, opencode, cline, gemini, and more — run asm install --help for the full list).
Also installable as a Claude Code plugin — .claude-plugin/plugin.json at the repo root (separate from the root plugin.json, which serves GitHub's Copilot CLI plugin marketplace format). And as a Codex plugin — the repository is its own one-plugin marketplace: `codex plugin
暂无开放 Issues,或尚未同步最近议题。