A 5-layer Claude Code workflow system to eliminate context loss
After 8 months of daily Claude Code use, 马国锦 distilled a 5-layer workflow — CLAUDE.md, plan-first mode, small atomic tasks, disciplined git commits, and git worktrees — that eliminates per-session context re-establishment and keeps projects in a runnable state at every step.
Score breakdown
The system directly addresses the structural reason Claude Code sessions lose productivity — no persistent project memory — by encoding context in `CLAUDE.md` and enforcing workflow discipline that keeps every session starting with full context and every change safely reversible.
- 01The author reports spending roughly 20% of every session on context re-establishment without a structured workflow.
- 02Layer 1 is a `CLAUDE.md` file at the project root; Claude reads it automatically at the start of every session.
- 03A good `CLAUDE.md` encodes unique project details: tech stack, architecture, commands, and conventions — not generic advice.
马国锦 argues that most developers use Claude Code like a stateless chatbot — opening a terminal, asking a question, and starting from scratch the next day — which wastes roughly 20% of every session on context re-establishment. The fix is a 5-layer system where each layer depends on the previous one.
Layer 1 is a project-specific `CLAUDE.md` at the repo root, which Claude reads automatically at session start.
Layer 1 is a project-specific `CLAUDE.md` at the repo root, which Claude reads automatically at session start. The post contrasts a bad example (generic advice like "write clean code" and "use Git") with a good one that encodes the actual tech stack (`FastAPI + LangChain + Milvus + PostgreSQL + Redis`), startup and test commands, request-flow architecture, key directory roles, and project-specific API conventions. Layer 2 is plan-first mode: for any change touching 3 or more files, Claude explores the codebase, proposes an implementation plan, and only writes code after explicit approval. Layer 3 is atomic tasking — each task changes one logical unit so the project remains runnable after every step, illustrated with a step-by-step retriever refactor across separate commits. Layer 4 is disciplined git commits after every small task, turning the commit history into a traceable project journal. Layer 5 is `git worktree`, used to fix bugs in complete isolation while a feature branch is in progress, either manually or by telling Claude to handle the isolation.
The post also describes a three-level knowledge storage hierarchy — `CLAUDE.md` for project architecture, a session memory system for user preferences and corrections, and a linked notes knowledge base for broader methodologies — which the author says compounds over time so the assistant understands not just the project but the developer's thinking patterns.
Key facts
- 01The author reports spending roughly 20% of every session on context re-establishment without a structured workflow.
- 02Layer 1 is a `CLAUDE.md` file at the project root; Claude reads it automatically at the start of every session.
- 03A good `CLAUDE.md` encodes unique project details: tech stack, architecture, commands, and conventions — not generic advice.
- 04Layer 2 is plan-first mode: triggered by any change touching 3 or more files, Claude proposes a plan before writing any code.
- 05Layer 3 requires each task to change ONE logical unit so the project stays runnable after every step.
- 06Layer 4 treats git commits after every small task as a project journal, making regressions traceable to a specific commit.
- 07Layer 5 uses `git worktree` to isolate parallel work (e.g., a hotfix) without interrupting the current feature branch.
Topics
Summary and scoring are generated automatically from the original article. We always link back to the publisher and never republish images or paywalled content. Last processed Jun 11, 2026 · 08:34 UTC. How this works →