Skip to main content
Claude Code has two systems for managing state that persists beyond a single exchange: the memory system for knowledge that should survive across sessions, and the task system for work items that run in the background or in parallel.

Memory system

Location: src/memdir/ Claude Code’s persistent memory is based on CLAUDE.md files. These plain Markdown files are read at session start and injected into the context, giving Claude awareness of project conventions, user preferences, and previously captured facts.

Memory hierarchy

File: CLAUDE.md in the project rootStores project-specific facts, coding conventions, architecture decisions, and team norms. Committed to version control so the whole team benefits.
# Project conventions

- Use `pnpm` for all package management
- All new components go in `src/components/`
- Run `pnpm test` before committing

Managing memory

/memory command

View, edit, and clear memory entries directly from the REPL.

remember skill

Invoke the remember skill to explicitly persist a fact from the current session to memory.

useMemoryUsage hook

The useMemoryUsage React hook tracks how much of the context window is consumed by memory content.

Task system

Location: src/tasks/ The task system manages background and parallel work items — shell commands, local agents, remote agents, and parallel teammate processes.

Task types

Location: src/tasks/LocalShellTask/Executes a shell command in the background. The main session continues while the command runs, and output is captured for later retrieval.
Location: src/tasks/LocalAgentTask/Runs a sub-agent locally. The sub-agent has its own context and tool access, operating independently from the main session.
Location: src/tasks/RemoteAgentTask/Runs an agent on a remote machine. Enables distributing work across multiple hosts.
Location: src/tasks/InProcessTeammateTask/A parallel teammate agent running in the same process. Used for concurrent work on different parts of a task.
Location: src/tasks/DreamTask/A background “dreaming” process that runs autonomously in the background while the user is not actively interacting.
Location: src/tasks/LocalMainSessionTask.tsWraps the main interactive session as a task, enabling it to participate in the task management system.

Task tools

The task system exposes six tools for managing work items:
ToolPurpose
TaskCreateToolCreate a new background task
TaskUpdateToolUpdate task status or metadata
TaskGetToolRetrieve details for a specific task
TaskListToolList all active and completed tasks
TaskOutputToolRetrieve the output of a task
TaskStopToolStop a running task

Coordinator (multi-agent)

Location: src/coordinator/ The coordinator orchestrates multiple agents working in parallel on different aspects of a task. It is gated behind the COORDINATOR_MODE feature flag.
The coordinator is an advanced feature gated behind COORDINATOR_MODE. It is stripped from standard builds. Enable it only in environments designed for multi-agent workflows.

How it works

1

Coordinator lifecycle

coordinatorMode.ts manages the full coordinator lifecycle — startup, agent registration, message routing, and shutdown.
2

Team creation

TeamCreateTool and TeamDeleteTool create and disband named agent teams. Each team can work on a distinct subtask in parallel.
3

Inter-agent communication

SendMessageTool enables agents to communicate with each other — passing results, asking for clarification, or handing off work.
4

Sub-agent spawning

AgentTool spawns individual sub-agents on demand, giving the coordinator fine-grained control over parallelism.

Coordinator tools

TeamCreateTool

Creates a named team of agents assigned to a specific subtask.

TeamDeleteTool

Disbands a team once its work is complete.

SendMessageTool

Sends a message from one agent to another for inter-agent coordination.

AgentTool

Spawns a new sub-agent with a given task and context.

Build docs developers (and LLMs) love