Skip to content

Lean Agent Kit Guide

Canonical playbook for the 1.0 lean core and optional packs. Ship this file with every install as /guide.

1. Mental model

Lean Agent Kit is context economics:

Trevor — Lean Agent Kit concierge
  1. Lean context — sessions start from ACTIVE_CONTEXT + CODEBASE_MAP + recent LEARNINGS, then open named files. Narrow search is allowed when the map is wrong or incomplete.
  2. Lean footprint — default install is core only. Packs are opt-in overlays.
  3. Ambient memory — refresh focus/resume as side effects of work; capture avoidable failures into LEARNINGS.md. Session skills are optional wrappers.

It is not a replacement for your editor agent’s tools. It is a small set of trustworthy files so work resumes accurately.

2. Core files

PathPurpose
AGENTS.mdProject identity, commands, conventions, protocol
docs/CODEBASE_MAP.mdWhere things live
docs/memory/ACTIVE_CONTEXT.mdWhat we’re doing now
docs/memory/LEARNINGS.mdAvoidable-mistake inbox → promote to AGENTS.md
.agent/skills/leanagentkit-*.mdPortable procedures
.agent/.leanagentkit-versionVersion + installedPacks

3. Map-first protocol

  1. Read ACTIVE_CONTEXT.md, then CODEBASE_MAP.md, then skim Open LEARNINGS.md.
  2. Open files they name.
  3. If needed, search narrowly (symbol, path prefix, tests for one module).
  4. Do not re-scan the whole repository to “get oriented.”

4. Ambient memory

Default path is ambient for core focus/resume. Update memory on triggers (see AGENTS.md §6):

TriggerUpdate
Focus shiftsACTIVE_CONTEXT focus + Resume
Meaningful editsFiles in play (+ Resume)
Structure changeCODEBASE_MAP
Avoidable failureAppend/bump LEARNINGS
Context full mid-taskExplicit handoff
User stoppingFinalize (§6): core-only may skip end-session; packs/spec require it

leanagentkit-start-session is optional (backlog/trevor preamble). leanagentkit-end-session is finalize when spec / backlog / git-lifecycle / trevor are installed — ambient ACTIVE_CONTEXT alone does not run PROGRESS or pack hooks.

5. Workflow sizes

SizeUse whenLoop
TrivialTiny fix, questionWork only; update ACTIVE_CONTEXT if focus changes
NormalDay-to-day codingWork with ambient touches → check → finalize
SubstantialFuzzy/new featureRequires spec pack: grillnew-specimplement-speccheck → finalize

Mid-task context full → handoff → new chat → ambient §6 start (optional start-session).

6. Bookkeeping budget

  • Keep ACTIVE_CONTEXT Resume concrete via ambient touches (not only at goodbye).
  • Map: only if structure changed.
  • LEARNINGS: on avoidable failures (including when AGENTS.md already had the rule).
  • PROGRESS / SCRATCH / ADRs / specs: via finalize / end-session when the spec pack is installed.
  • Do not turn every typo fix into a session ritual.
  • Core-only: skipping end-session is OK if ACTIVE_CONTEXT is current. With packs above, run end-session at stop.

7. Self-improvement (LEARNINGS.md)

Append-only inbox of mistakes that should not repeat. Skim Open at task start.

Capture when: something failed/redone; one-line Avoid; likely to recur. Still capture when the same Avoid is already in AGENTS.md but was violated again (salience).

Promote when Seen: ≥ 3 — offer to add or strengthen a one-liner in AGENTS.md §4 or §5 only after user confirms. Cap Open at ~20; merge duplicates by bumping Seen:.

Example: commitlint rejects a long subject → shorten → append commits learning → next commit reads it → after repeats, harden §4 Commits / §5 Never do.

Skill ## Learned notes (authoring pack / generated skills) are for skill gotchas. Project-wide scars live in LEARNINGS.md.

8. Core skills

SkillWhen
leanagentkit-bootstrapFirst setup
leanagentkit-map-codebaseBuild/refresh map
leanagentkit-init-conventionsFill AGENTS §1–5 (merge + backup if file exists)
leanagentkit-wire-agentCursor / Claude wrappers
leanagentkit-start-sessionOptional prime + pack hooks
leanagentkit-end-sessionFinalize (+ required with packs/PROGRESS)
leanagentkit-handoffContext full mid-task (explicit)
leanagentkit-checkConvention check + LEARNINGS capture
leanagentkit-enable-packAdd packs
leanagentkit-migrate-10.x → 1.0

Invoke: Read .agent/skills/leanagentkit-<name>.md and follow it.

9. Packs

Install:

bash
npx create-lean-agent-kit@latest . --with spec,stacks          # first scaffold
npx create-lean-agent-kit@latest . --enable-pack practice      # existing install
npx create-lean-agent-kit@latest . --prune-to-core             # drop pack overlays
npx create-lean-agent-kit@latest . --prune-to-core --keep-pack spec
PackDependsSummary
specGrill, specs, implement, spike, ADRs, PROGRESS/SCRATCH
stacksRegistry, match-stack, scaffolders
practiceReview, debug, TDD, security, performance, …
architecturespecCA/DDD decompose + slices
backlogspecBacklog.md status sync
git-lifecyclespecBranch/commit/PR offers
trevorConcierge, reminders, checklists
cavemanTerse commits / reviews
authoringCreate / distill / curate skills
imaginaryResize / crop / convert via h2non/imaginary

Docs: Packs · Migration · Stacks · Backlog · Trevor · Caveman · Git lifecycle · Architecture · Create skill · Imaginary.

Substantial work (spec pack)

grill → new-spec → implement-spec → check → finalize

Optional: decompose-spec when architecture pack + config enabled.

Spec vs plan: The feature spec (docs/specs/NNN-*.md) owns intent — Problem, Goal, Scope, acceptance criteria, and locked decisions. A portable implementation plan lives in the same file (Implementation order, Test plan, Done when) or an optional companion NNN-*-plan.md.

Cursor Plan + Build: On Cursor, when Plan mode is available, implement-spec hands "Plan then build" to Cursor Plan mode and Build (the IDE orchestrator — often multi-agent). It does not also run a sequential LAK implement loop in the same chat. If the host is not Cursor, or Plan mode is unavailable, or the user declines Plan, implement-spec bypasses to the portable implement path. Non-trivial specs should still fill Implementation order before coding on any host.

10. Anti-patterns

  • Requiring start/end session for every one-line fix.
  • Skipping end-session when packs need PROGRESS / backlog / git / trevor hooks.
  • Forbidding all search because “the map exists.”
  • Enabling every pack “just in case.”
  • Letting ACTIVE_CONTEXT go stale for weeks.
  • Ignoring repeated hook/lint failures without a LEARNINGS note.
  • Treating optional integrations (Backlog, Trevor) as required.

11. Troubleshooting

SymptomFix
Agent ignores conventionsFill AGENTS §4–5; run check; promote LEARNINGS
Cold start every timeAmbient Resume note (or finalize) with real next
Repeat commitlint failsAppend commits learning; promote after 3×
Too many skills / noise--prune-to-core, enable only needed packs
Stale mapmap-codebase or narrow search + update map
0.x clutter after upgrademigrate-1 / --prune-to-core

12. Cheat sheet

bash
# Install core
npx create-lean-agent-kit@latest .

# Packs
npx create-lean-agent-kit@latest . --enable-pack spec,stacks

# Upgrade / prune
npx create-lean-agent-kit@latest . --upgrade
npx create-lean-agent-kit@latest . --prune-to-core
Trivial:     just work
Normal:      ambient work → check → finalize
Substantial: grill → new-spec → implement-spec → check → finalize
Handoff:     handoff → new chat → ambient §6 start
Learning:    fail → LEARNINGS append/bump → retry → promote at Seen ≥ 3

❤️ Free and open source forever under the MIT License.