Guide
How the code rules, AGENTS.md, the session handoff and the hook work. Then the Session Status Mod and the Explainer Agent. Utilities are on the extras page.
On this page: YAGNI ladder · AGENTS.md · /endsession · The session-start hook · Why sessions should be short · Session Status Mod · Explainer Agent · Install details · Extras
The YAGNI ladder
YAGNI means "you aren't gonna need it". First the assistant lists every place the change must reach (callers, tests, fixtures, config) and what it could break. That is the scope; extra features are not. Then it stops at the first step that works:
- Only maybe needed later? Skip it and say so.
- Already in the project? Reuse it.
- In the standard library? Use it.
- Native to the platform (browser, OS, framework)? Use it.
- An installed dependency does it? Use it.
- Fits in one line a reader gets at a glance? One line.
- Otherwise, the smallest new code that works.
Minimal never means careless. It never cuts input validation at trust boundaries, error handling against data loss, security, accessibility, or anything you asked for. Also:
- Complete change. Lazy about the solution, never about the change: it finishes the callers and tests the change breaks. Code it moves keeps its validation and error handling.
- Root cause. A bug is fixed at the shared place it comes from, not in every caller.
- Labeled shortcuts. A deliberate shortcut gets a comment such as
// lean: up to 1,000 rows, stream if larger: the limit, then what to do past it./lean-and-mean:lean-and-mean debtlists them. - One runnable check for logic with branches, loops, parsing, money or security.
- A skipped note. After code, at most three lines say what was left out or not checked, any risk, and when to add it.
AGENTS.md
One file holds the rules, the next task and the project facts. Codex loads it directly; Claude Code loads it through a CLAUDE.md that holds only @AGENTS.md.
- Rules. Each correction becomes one dated line. The cap is 15, so the list stays readable.
- Next.
## Nextnames the next task, then a backlog sorted P1 to P3. History stays ingit log. - Fixed layout. Operating Mode, Project & Stack, Commands, Architecture & Layout, Done, Rules, Next, Notes & Pointers, always in that order. A sub-project can keep its own
AGENTS.mdin the same layout. - 250-line cap. The file is resent on every request. Overflow moves to linked
agents-<category>.mdfiles.
/endsession
The last message of a session. It turns this session's mistakes and failed approaches into Rules, rewrites ## Next and its backlog, flags a full review for the next session if the project's layout or commands changed, then commits and pushes, opening a PR when the branch is a feature branch or the default branch is protected. It never force-pushes. Then it prints a short summary of what was done, what was updated and what comes next. Then it stops.
- Hard stop. Anything you pass that looks like a task is written under
## Next, not done. The model never invokes it on its own. - One question round. It asks once, up front, about at most three deletes that would remove a Rule or P1 Next item it can't judge. Clearly stale entries are dropped without asking. It never asks whether to commit or push: running it is the yes.
- One memory. In Claude Code, project
feedbackandprojectentries from built-in auto memory are moved into Rules or Next, then deleted, so the committedAGENTS.mdis the single place lessons live.userandreferencememories are left alone. - Light on purpose. Context is largest at the end of a session, so the full
AGENTS.mdreview waits for the next session's fresh, cheap context./endsessiononly leaves a<!-- lean-and-mean: review -->flag. - Definition of done.
AGENTS.mdhas a## Donesection listing what finished means for this project, with exact commands: say, merge the PR withgh pr merge --squash --delete-branch, thenmake deploy-staging. It defaults to committed and pushed. When the session's work is complete (what you asked is finished, the project's tests pass, no open question),/endsessionruns those steps in order after pushing, then deletes local branches already merged into the default branch withgit branch -d. Otherwise, or when a step fails,## Nextopens withNot done: <what remains> — <why>, so the next session picks it up. It only runs commands written in## Doneor## Commands, never a deploy it guessed. The Session Status Mod's timed auto end never ships. - Safe push. Files that look like secrets (
.env, keys, credentials) are never staged; they are named in the summary. A push behind the remote stops without rebasing. Any other push failure gets one attempt, thenUnpushed: <branch> — <reason>becomes the first line of## Next.
The session-start hook
One short POSIX shell script runs when a session starts. Once the ## Operating Mode block is in AGENTS.md, the mode needs no hook, flag or per-turn reminder: the host loads the file natively. The hook only covers the gaps:
| Condition | What it prints |
|---|---|
Block missing from AGENTS.md | The block itself, so the mode is active anyway, plus a nudge to run /lean-and-mean |
| Block differs from the plugin's current copy (plugin updated) | An instruction to run the full /lean-and-mean pass before your first task, then re-read AGENTS.md: the new file replaces the copy the host loaded at start |
AGENTS.md over 250 lines | |
/endsession left the review flag | |
Claude Code: CLAUDE.md is anything but @AGENTS.md | |
Claude Code: ~/.claude/statusline.sh missing or its version line old | A one-line suggestion to run /lean-and-mean:statusline |
| Anything else | Nothing |
The pass runs at session start, not in /endsession, because the context is small then and each call is cheap. The CLAUDE.md check is also the upgrade path: a 3.x project kept its block in CLAUDE.md, so the pass merges that file into AGENTS.md and writes the one-line stub. Anything added to CLAUDE.md later moves over the same way. A CLAUDE.local.md keeps working alongside the stub.
Why sessions should be short
Every tool call resends the whole context, so cost scales with requests × context size. In the maintainer's logs (63 sessions, Sept–Oct 2026, API list prices), a request over 400K context cost 4× one under 100K, and a resume after the one-hour cache expired cost a median 4.5× a fresh start. /endsession writes the handoff for a median $0.27. So end at task boundaries and before breaks.
Measured, not a billing model; actual costs depend on host, model and caching.
Session Status Mod
The Session Status Mod is a row above the Claude Code prompt. It is a mod: a plugin module of function hooks that runs inside the session. The code is hooks/register.tsx, with helpers in hooks/cache.ts. hooks/hooks.json lists it under modules. It is the only plugin code that runs on every turn.
It is Claude Code only and on by default. Turn it off in /config under Session Status Mod. On Codex, use the separate macOS companion. The Claude mod writes nothing to your project; its state lives in Claude Code's plugin storage.
Cache Idle █████████░░░ 42m [ end session ]
- Desktop app. The row moves into its own Session pane, which opens when the session starts or the app attaches. If the app has no room for it then, your next prompt places it. The app decides where the pane sits: a plugin pane gets a panel of its own, not a place in the app's session rail. The pane draws the bar as a rounded graphic and lists the session's tasks. Above the bar it names the project folder and the git branch, plus the worktree folder when the session runs in one; then it shows how full the context window is and each subscription limit the last reply reported (5h, weekly), as bars of the same kind: green under 50%, yellow under 75%, orange under 90%, red after that. The context bar is pale up to where it stood at your last prompt and solid for what the reply added, with the growth as
+N%; the weekly bar does the same for today's use and shows the time to the next weekly reset in small text below it. - End session button. On desktop it is the pane's primary button, ⏻ End Session. It runs
/lean-and-mean:endsession. If the command cannot run, it fills the prompt box with it instead. - Tasks (desktop). The pane mirrors the task list the desktop app shows under the latest message: ✓ done, ● in progress, ○ pending. The mod copies the app's own plan tool calls, so it makes no model calls. The terminal shows its own task list, so the row has none.
- Next sessions (desktop). A brief list of the
## Nextsection ofAGENTS.md: each line cut to its first clause, with its P1–P3 priority. The mod reads the file at session start and at the end of each turn, so a rewrite by/endsessionshows at once, with no model calls. - Reset.
/clearresets the cache timer.
The cache clock
The prompt cache lasts one hour. Each main turn restarts that hour. The mod tracks it and acts at two points:
/endsession itself. Rules and Next are saved while the context is still cheap to read.- Auto end. At 55 minutes, the mod runs
/lean-and-mean:endsession auto. It commits and pushes, butautomeans it never ships. It fires only if no turn is running and you sent a real prompt since the last/endsession. Any/endsession, typed, button or auto, disarms it until your next real prompt. - Cache Idle. The top line of the mod shows the time since the last reply as a bar and minutes, such as
Cache Idle █████░░░░░░░ 21m, in the terminal; the desktop pane draws the same bar as a graphic. The minutes count up and the bar fills as the cache ages; at 60 minutes it reads cold. The time survives a restart or resume of the session; a session with no reply since the plugin loaded shows waiting for a reply. It is green under 30 minutes, yellow under 45, orange under 50, and red after that. While Claude is working on a turn, the bar is full and blue with BUSY in the middle, and the timer does not run; it starts again from 0 when the reply ends.
The cold-cache question
After the hour, the next request resends the whole context at full price. So the mod asks before it sends a prompt into a cold cache:
- Rehydrate sends the prompt. The whole context is resent once at full price.
- Clear first does not send the prompt. After any
/endsession, auto, button or typed, it fills/clear: Next is already inAGENTS.md. Otherwise it fills/lean-and-mean:endsession, so Rules and Next are saved before you clear. - Your prompt is not kept after Clear first. Retype it after
/clear. - Dismissing the question sends the prompt. A cache miss is better than a lost prompt.
Explainer Agent
A subagent, Claude Code only, that writes .pages/<slug>.html: one page for an answer too long or too structural for the terminal. The Operating Mode block tells Claude to explain in the cheapest form that works: a sentence, then a diagram, then a page. Call it directly with @agent-lean-and-mean:explainer.
- Markdown only. The agent writes a three-line shell and a Markdown body. The explainer kit renders it: type, both themes, contents rail, code highlighting, Mermaid diagrams and fifteen components. A page costs a fraction of the tokens of hand-written HTML and SVG.
- Answer first. The first paragraph becomes the summary box. Sections follow, in concise, active sentences that broadly follow ASD-STE100.
- Style, asked once. On first use the agent replies
STYLE?; Claude asks you for dark, light or auto, dense or airy, and one accent colour. The agent saves it in its user memory. - Network. Pages load the kit from this site and its libraries from cdnjs and jsDelivr, at pinned versions. Offline, the browser shows the Markdown source. The agent reads the project but writes only
.pages/, which it gitignores, and has no shell access.
Install details
Claude Code. In the app, /plugin marketplace add https://github.com/spinlockdevelopment/lean-and-mean then /plugin install lean-and-mean@lean-and-mean does the same as the shell commands. Restart afterwards: the hook loads only at session start.
Claude Code, manual: copy skills/lean-and-mean/ and skills/endsession/ into ~/.claude/skills/, copy hooks/session-start.sh somewhere, and add the SessionStart entry from hooks/hooks.json to ~/.claude/settings.json, pointing at that script. Manual installs get the bare /endsession and /lean-and-mean.
Codex desktop and CLI. Run these commands in a terminal.
codex plugin marketplace add https://github.com/spinlockdevelopment/lean-and-mean
codex plugin add lean-and-mean@lean-and-mean
Reopen Codex and review the SessionStart hook in desktop Settings → Hooks or CLI /hooks. Start a chat at the project root and run $lean-and-mean. Codex loads nested instruction files too. If the root has an AGENTS.override.md, Codex gives it precedence over AGENTS.md. The hook uses a POSIX shell on macOS, Linux, or WSL.
For a local checkout, pass the absolute path to the repository root to codex plugin marketplace add, then run the same plugin add command. For a Git marketplace, run codex plugin marketplace upgrade lean-and-mean to refresh it, then reopen Codex. See Codex CLI reference.
Run $endsession for a manual wrap-up. On macOS, Codex Companion adds an optional floating panel with an activity-based cache estimate and an End Session button.
Codex without plugin support: copy both skill folders into ~/.agents/skills/ and run $lean-and-mean yourself. The mode persists, but there is no automatic session-start review.
Turning it off. Disable the plugin and delete the Operating Mode block. Disabling alone leaves the rules active; deleting alone lets the hook suggest setup again.