---
name: agent-development-loop
description: Runs a continuous improvement cycle — consult memory, complete the next TODO, test and build, harvest learnings back to memory, then research the competition. Use when maintaining a codebase over many agent sessions, when institutional knowledge keeps getting lost between sessions, or when progress needs a repeatable flywheel.
category: loop-engineering
keywords: dev-loop, memory, todo, harvest, continuous-improvement, flywheel
---

# Agent Development Loop

## When to apply

Use when an agent (or human) maintains a project across many sessions and needs progress to compound instead of restarting from zero each time. The loop lives in `AGENTS.md`; its memory lives in `MEMORY.md`; its backlog lives in `TODO.md`.

## The cycle

1. **Consult memory first** — Search MEMORY.md for the task's keywords before starting. Reuse proven patterns; respect documented anti-patterns. If nothing relevant exists, note the gap.
2. **Pick one TODO item** — Highest priority first; minimal, focused change; no speculative features. If the backlog is empty, run a competitive-intelligence pass to seed it.
3. **Test and build** — Run the full verification chain (typecheck → tests → build). A feature that isn't verified doesn't exist.
4. **Harvest** — Write what worked, what failed, and why into MEMORY.md with file/line references and dates. Check the harvest quality list: success patterns, anti-patterns, project gotchas, searchability.
5. **Audit periodically** — After each batch: leanness (dead code, unused deps), budgets (bundle size, performance), consistency (design tokens, conventions), docs alignment (drift is a bug).
6. **Research the ecosystem** — Study competitors, note capabilities they have that this project lacks, add the valuable ones to TODO.md.
7. **Loop** — Back to step 1.

## The two files that make it work

- **MEMORY.md is both entrance and exit**: consult it before work, harvest into it after. Knowledge that isn't written down dies with the session.
- **TODO.md is the queue**: finished work is marked done in the same session that finished it. An honest backlog beats a hopeful one.

### Example MEMORY.md entry

```markdown
### Prerender parity (2026-08-30)
- Client and SSR must import the same route components (lazy vs static)
  or hydration mismatches occur. See src/routes.tsx vs src/entry-server.tsx.
- Symptom: blank page in production, works in dev. Check dist/ HTML for
  the expected content — if missing, the SSR render failed silently.
```

### Example TODO.md entry

```markdown
- [ ] Lazy-load skill bodies (bundle budget fix): import.meta.glob eager
      bundles all 23 skill bodies into the initial chunk. Fix: non-eager
      glob + async getSkillBySlug. Brings initial bundle under 105KB gz.
```

## Rules

- Never skip step 1 to "save time" — that trade always costs more later.
- Harvest even from failures, especially from failures.
- Keep entries dated and searchable; stale memory is worse than none when it's trusted blindly.
- Docs are code: when implementation changes, the docs change in the same commit.

## Related skills

- [loop-budget](/skills/loop-budget) — Bounds what a single loop cycle may spend.
- [loop-triage](/skills/loop-triage) — Decides what enters the TODO queue.
