lean-and-mean · Guide

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:

  1. Only maybe needed later? Skip it and say so.
  2. Already in the project? Reuse it.
  3. In the standard library? Use it.
  4. Native to the platform (browser, OS, framework)? Use it.
  5. An installed dependency does it? Use it.
  6. Fits in one line a reader gets at a glance? One line.
  7. 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:

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.

/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.

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:

ConditionWhat it prints
Block missing from AGENTS.mdThe 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 oldA one-line suggestion to run /lean-and-mean:statusline
Anything elseNothing

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 ]

The cache clock

The prompt cache lasts one hour. Each main turn restarts that hour. The mod tracks it and acts at two points:

The one-hour cache clock At 0 minutes the last turn ends. At 50 minutes the Cache Idle timer turns red. At 55 minutes the mod runs /endsession auto. At 60 minutes the cache is cold. 0m last turn ends 50m timer turns red 55m auto /endsession 60m cache cold
Five minutes before the cache goes cold, the mod runs /endsession itself. Rules and Next are saved while the context is still cheap to read.

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:

What happens to a prompt sent into a cold cache You type a prompt that is not a slash command. If the cache is not over one hour old, or a turn is running, the prompt is sent. Otherwise a Cold cache question opens. Rehydrate or dismiss sends the prompt. Clear first holds it back. If an /endsession ran since your last prompt, the prompt box gets /clear. If not, the prompt box gets /lean-and-mean:endsession. You type a prompt not a /command Cache over 1h old and no turn running? Prompt is sent Cold cache question Rehydrate · Clear first /endsession ran since your last prompt? Box gets /clear Next is already saved Box gets the end command /lean-and-mean:endsession no yes Rehydrate or dismiss Clear first yes no
Rehydrate pays one full resend and keeps working. Clear first holds the prompt back and fills the next command for you.

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.

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.