Building a Stateful Agent on Claude Code
How to turn Claude Code into a persistent agent using the three-layer pattern — skills for capabilities, a profile for identity, and context files for memory across sessions.
How to turn Claude Code into a persistent agent using the three-layer pattern — skills for capabilities, a profile for identity, and context files for memory across sessions.
Claude Code is powerful out of the box. But every conversation starts fresh. It doesn't know what you were working on yesterday. It doesn't remember what you decided last week. It doesn't know your preferences, your goals, or the commitments you made. Each session is a blank slate.
If you want to build something that behaves more like an agent — something that remembers, adapts, and operates across sessions — you need to add those layers yourself.
This post breaks down the architecture pattern I used to build the AI Executive Assistant, a 13-skill agent that manages my daily workflow, tracks my commitments, and holds me accountable across conversations. No frameworks. No databases. No vector stores. Just files, prompts, and a clear pattern.
Every stateful agent needs three things: something that defines what it can do, something that defines who it's doing it for, and something that remembers what happened before.
A skill is a markdown file in ~/.claude/commands/ that becomes a slash command. That's it. Each file is a detailed prompt that handles one specific job.
~/.claude/commands/
├── ea-morning-brief.md → /ea-morning-brief
├── ea-meeting-prep.md → /ea-meeting-prep
├── ea-delegate.md → /ea-delegate
├── ea-weekly-retro.md → /ea-weekly-retro
└── ... (13 skills total)
What makes a skill different from just a good prompt? Structure. Each skill has:
A morning brief skill doesn't just say "plan my day." It says: read the calendar, read the task cache, check if the cache is stale, pull fresh data if needed, split tasks by size, score by Impact × Urgency, check capacity against 80% buffer, match to energy windows, present in this specific format, self-check against this list, then write the approved plan to this file.
The specificity is the point. Vague prompts produce vague results. Structured skills produce consistent, reliable behavior.
The profile is a single file — ~/.claude/ea-profile.md — that tells the agent who you are. Every skill reads this file before responding.
What goes in a profile:
The profile is what makes the agent yours without fine-tuning. Two people with the same skills installed get completely different experiences based on their profiles. One person's morning brief starts at 5:30am with deep work blocks. Another's starts at 9am with a meeting-heavy schedule. Same skill, different behavior.
Context files live in ~/.claude/ea-context/ and persist between conversations. Each file serves a specific purpose:
| File | What it holds |
|---|---|
today.md | Today's approved plan (or tomorrow's draft from the night cleanup) |
weekly-plan.md | This week's outcomes, sprint goal, day-by-day task slots |
monthly-goals.md | 3 focus areas with success criteria |
task-cache.md | Snapshot of all active tasks with sizes, dates, statuses |
velocity.md | Daily and weekly completion data, rolling trends |
waiting-on.md | Delegation follow-ups with reminder dates |
decisions.md | Key decisions made (for consistency and reference) |
delegation-log.md | Full history of delegated tasks |
Each skill knows which context files to read and which to write. The morning brief reads today.md (for last night's draft), weekly-plan.md, monthly-goals.md, and waiting-on.md. After you approve the plan, it writes to today.md and updates task-cache.md.
This creates a feedback loop: skills produce data that other skills consume. The night cleanup writes a draft. The morning brief reads it. The check-in writes velocity data. The weekly retro analyzes it. Nothing is wasted.
Why files instead of a database? Because files are readable, editable, debuggable. You can open today.md in any text editor and see exactly what the agent thinks your plan is. You can fix a wrong entry by hand. You can version control your context with git. There's no abstraction layer hiding what's happening.
Some skills run with your active involvement (morning brief, meeting prep). Others run autonomously (night cleanup). The autonomous ones need explicit guardrails.
The night cleanup skill has a clear boundary:
Can do without permission:
Cannot do without explicit approval:
This isn't just a nice-to-have — it's a trust requirement. If an autonomous agent can silently mark your tasks as done or delete things, you'll stop trusting it. If it can only organize and suggest, you stay in control while offloading the tedious work.
When designing your own autonomous skills, ask: "If this runs while I'm asleep and makes a mistake, what's the blast radius?" If the answer is "it moves a task to the wrong date," that's recoverable. If the answer is "it tells a client the project is done," that's not. Draw the line accordingly.
An agent is only useful if people can install it. The EA uses a simple pattern:
install.sh copies skills to ~/.claude/commands/, creates the context directory from templates, and sets up the profile template. It never overwrites existing profiles or context — your personalization is preserved across updates.
uninstall.sh removes skills and asks whether to keep or delete your profile and context.
git pull && ./install.sh updates skills to the latest version without touching your data.
This means the agent is:
When I started, I assumed building an agent required:
It doesn't. The entire EA is markdown files — prompts with structure. The "orchestration" is just each skill knowing which files to read and write. The "memory" is just files that persist on disk. The "framework" is just Claude Code's built-in slash command system.
This isn't to say frameworks are useless. For complex multi-agent systems with tool calling, parallel execution, and error recovery, they earn their complexity. But for a single-agent system that needs to remember things and act consistently, files and prompts are enough. Start simple. Add complexity only when simple breaks.
If you want to build a stateful agent on Claude Code, here's the minimum:
~/.claude/commands/ — start with the thing you do most oftentoday.md.Get that working. Use it for a week. You'll quickly see what's missing — "I wish it remembered what I delegated" → add waiting-on.md. "I wish it knew my energy patterns" → add energy windows to your profile. "I wish it could review my week" → add a retro skill.
The EA has 13 skills, a detailed profile format, and 8 context files. It didn't start that way. It started with a morning brief and a task list. Everything else grew from actual needs.
How connecting your tools via MCP transforms an AI agent from a smart guesser into an informed operator — and why it's simpler than you think.
What I learned building my first AI agent from scratch — what surprised me, what I got wrong, and what I'd tell someone starting today.
A four-phase daily workflow — morning planning, active work, afternoon review, and nightly cleanup — where each phase feeds into the next so you never start from zero.