A battle-tested workflow template for Claude Code — memory management, context engineering, and task routing from 3 months of daily usage across multiple projects.
Not a tutorial. Not a toy config. A production workflow that actually ships.
Claude Code is powerful out of the box, but without structure it becomes a smart assistant that forgets everything between sessions. This template turns it into a persistent, self-improving development partner that:
- Remembers past mistakes and applies lessons automatically
- Manages context across long sessions without drifting
- Routes tasks to the right model tier (Opus/Sonnet/Haiku/Codex/Local)
- Forces verification before claiming completion (no more "should work now")
- Auto-saves progress so closing the window doesn't lose work
┌─────────────────────────────────────────────────────────┐
│ Layer 0: Auto-loaded Rules (always in context) │
│ ┌─────────────┐ ┌────────────┐ ┌───────────────┐ │
│ │ behaviors.md │ │skill- │ │memory-flush.md│ │
│ │ │ │triggers.md │ │ │ │
│ └─────────────┘ └────────────┘ └───────────────┘ │
├─────────────────────────────────────────────────────────┤
│ Layer 1: On-demand Docs (loaded when needed) │
│ agents.md · content-safety.md · task-routing.md │
│ behaviors-extended.md · scaffolding-checkpoint.md ... │
├─────────────────────────────────────────────────────────┤
│ Layer 2: Hot Data (your working memory) │
│ today.md · projects.md · goals.md · active-tasks.json │
└─────────────────────────────────────────────────────────┘
Why three layers? Context window is expensive. Loading everything wastes tokens and degrades quality. This system loads rules always (~2K tokens), docs only when relevant (~1-3K each), and keeps your daily state hot for instant recall.
claude-code-workflow/
├── CLAUDE.md # Entry point — Claude reads this first
├── README.md # You are here
│
├── rules/ # Layer 0: Always loaded
│ ├── behaviors.md # Core behavior rules (debugging, commits, routing)
│ ├── skill-triggers.md # When to auto-invoke which skill
│ └── memory-flush.md # Auto-save triggers (never lose progress)
│
├── docs/ # Layer 1: On-demand reference
│ ├── agents.md # Multi-model collaboration framework
│ ├── behaviors-extended.md # Extended rules (knowledge base, associations)
│ ├── behaviors-reference.md # Detailed operation guides
│ ├── content-safety.md # AI hallucination prevention system
│ ├── scaffolding-checkpoint.md # "Do you really need to self-host?" checklist
│ └── task-routing.md # Model tier routing + cost comparison
│
├── memory/ # Layer 2: Your working state (templates)
│ ├── today.md # Daily session log
│ ├── projects.md # Cross-project status overview
│ ├── goals.md # Week/month/quarter goals
│ └── active-tasks.json # Cross-session task registry
│
├── skills/ # Reusable skill definitions
│ ├── session-end/SKILL.md # Auto wrap-up: save progress + commit + record
│ ├── verification-before-completion/SKILL.md # "Run the test. Read the output. THEN claim."
│ ├── systematic-debugging/SKILL.md # 5-phase debugging (recall → root cause → fix)
│ ├── planning-with-files/SKILL.md # File-based planning for complex tasks
│ └── experience-evolution/SKILL.md # Auto-accumulate project knowledge
│
├── agents/ # Custom agent definitions
│ ├── pr-reviewer.md # Code review agent
│ ├── security-reviewer.md # OWASP security scanning agent
│ └── performance-analyzer.md # Performance bottleneck analysis agent
│
└── commands/ # Custom slash commands
├── debug.md # /debug — Start systematic debugging
├── deploy.md # /deploy — Pre-deployment checklist
├── exploration.md # /exploration — CTO challenge before coding
└── review.md # /review — Prepare code review
# Clone the template
git clone https://github.com/runesleo/claude-code-workflow.git
# Copy to your Claude Code config directory
cp -r claude-code-workflow/* ~/.claude/
# Or symlink if you want to keep it as a git repo
ln -sf ~/claude-code-workflow/rules ~/.claude/rules
ln -sf ~/claude-code-workflow/docs ~/.claude/docs
# ... etcOpen ~/.claude/CLAUDE.md and fill in:
- User Info: Your name, project directory, social handles
- Sub-project Memory Routes: Map your projects to memory paths
- SSOT Ownership Table: Define where each type of info lives
- On-demand Loading Index: Adjust doc paths if needed
claudeClaude will automatically load your rules and start following the workflow. Try:
- Start coding and notice the task routing ("🔀 Route: bug fix → Sonnet")
- Hit a bug and watch systematic debugging kick in
- Say "that's all for now" and see session-end auto-save everything
- Come back tomorrow and find your context preserved in
today.md
Every piece of information has ONE canonical location. The SSOT table in CLAUDE.md maps info types to files. Claude is trained to check SSOT before writing, preventing the "same info in 5 places, all outdated" problem.
Claude auto-saves progress on every task completion, every commit, and every exit signal. You can close the window mid-sentence and nothing is lost. No more "I forgot to save my context."
The most impactful rule: Claude cannot claim work is done without running the verification command and reading the output. Eliminates the #1 AI coding failure mode — "should work now" without actually checking.
Not every task needs Opus. The routing system automatically matches task complexity to model tier:
- Opus: Critical logic, security-sensitive, complex reasoning
- Sonnet: Daily development, analysis, most coding tasks
- Haiku: Simple queries, subagent tasks, quick lookups
- Codex: Cross-verification, code review, second opinions
- Local: Commit messages, formatting, offline work
System optimization happens on Sundays. On other days, if you try to tweak your workflow instead of shipping, Claude will intercept and remind you to focus on output. Configurable to any cadence you prefer.
- Add to
memory/projects.md - Add memory route in CLAUDE.md's "Sub-project Memory Routes"
- Create
PROJECT_CONTEXT.mdin the project root
Create skills/your-skill/SKILL.md with:
---
name: your-skill
description: What it does
allowed-tools:
- Read
- Write
- Bash
---
# Your Skill
[Instructions for Claude when this skill is invoked]Create agents/your-agent.md with:
---
name: your-agent
description: What it does
tools: Read, Grep, Glob, Bash
---
# Your Agent
[Agent personality, review dimensions, output format]Edit rules/behaviors.md → "Task Routing" section, and docs/task-routing.md for detailed tier definitions.
This template encodes several principles learned from daily AI-assisted development:
- Structure > Prompting: A well-organized config file beats clever one-off prompts every time.
- Memory > Intelligence: An AI that remembers your past mistakes is more valuable than a smarter AI that starts fresh each session.
- Verification > Confidence: The cost of running
npm testis always less than the cost of shipping a broken build. - Layered Loading > Flat Config: Don't dump everything into context. Load rules always, docs on demand, data when needed.
- Auto-save > Manual Save: If it requires the user to remember, it will be forgotten. Make it automatic.
- Claude Code CLI (Claude Max or API subscription)
- Optional: Codex CLI for cross-verification
- Optional: Ollama for local model fallback
This template draws from:
- Manus file-based planning approach
- OWASP Top 10 for security review patterns
- Real-world experience from building x-reader (650+ stars) and other open-source projects
MIT — Use it, fork it, make it yours.
Built by @runes_leo — more AI tools at leolabs.me — Telegram Community