Skip to main content
Claude CodeИИ автоматизацияAI-архитектура

Stabilizing Claude Code for Long Tasks: Persistent Lists & Sub-agents

Claude Code becomes significantly more reliable for long SDLC scenarios when initialized with a persistent task list (CLAUDE_CODE_TASK_LIST_ID) and when repetitive steps are delegated to sub-agents. For businesses, this prevents agent "drift" after context compaction and ensures the successful completion of complex workflows requiring over 50 steps, rather than stalling early.

Technical Context

I regularly observe the same failure pattern in autonomous development: the agent starts strong, completes 3–10 steps, and then "drifts"—confusing priorities, repeating completed actions, or losing track of done criteria. In Claude Code, this effect is especially noticeable after a compact (context compression) event or session restart. In practice, this issue isn't solved by a "longer prompt," but by the right supporting structure: task-lists + sub-agents.

Here is what I consider architecturally key: a task-list in Claude Code is not just a chat list. Since the updates in early 2026 (community often cites v2.1.16), task-lists have become persistent: they are saved to disk (usually in ~/.claude/tasks/), survive terminal closures, and partially compensate for the model's "RAM" loss during compression.

The most practical technique I use and recommend to teams is launching Claude Code so that it "sticks" to a specific task-list via an environment variable:

  • CLAUDE_CODE_TASK_LIST_ID=my-project — allowing you to work within the same task list even if the session breaks.

For managing the task-list, the interface offers quick commands (depending on the build, /tasks or toggling via Ctrl+T) and planning modes like Plan Mode. I view this as a "built-in orchestration layer": the agent shouldn't have to remember what it's doing every time—it must verify against the list at every step, mark items as done, and explicitly select the next item.

The second pillar is sub-agents. In Claude Code, these are usually spun up via agent management menus/commands (e.g., /agents, /agents create), while orchestration involves tool calls like TaskCreate({ subject: "..." }). The essence for me is simple: I offload the main agent's "cognitive load." Instead of holding requirements analysis, code edits, test runs, log reading, and documentation updates in one context, I create separate executors for repetitive or parallel chunks.

There is a practical limitation: parallelism cannot be expanded infinitely. I usually start with 2–5 sub-agents, because beyond that, coordination noise grows faster than productivity. The community mentions upper limits of around 7 parallel agents, but that shifts into "dispatcher required" mode rather than "self-driving."

Business & Automation Impact

Translating this to business language, task-lists and sub-agents transform Claude Code from "smart autocomplete" into a tool for AI automation of really long cycles: from task setting to PR, testing, and deployment. I don't view this as cosmetic. It's a change in control contours: instead of relying on the model's memory, we control the process through artifacts (task lists, checkpoints, sub-agent reports).

Who wins first:

  • Product teams with heavy routine SDLC: similar microservices, integrations, migrations, module refactoring.
  • Outsource/Integrators who need to predictably manage multiple workstreams, track progress, and reproduce results.
  • Internal Platform Owners who want to standardize "how an agent executes tasks" rather than hoping for the talent of an individual prompt engineer.

Who loses: those who continue managing the agent with a "wall of text prompt" lacking structure. I've seen such teams get an illusion of speed in the first 20 minutes, only to lose a day figuring out why the agent "did the wrong thing" after a compaction event or skipped a dependency.

In my projects at Nahornyi AI Lab, I mandate the task-list as a required layer for embedding AI into development: it replaces part of manual project management at the micro-step level. However, for this to work, the list must be measurable. Not "do authorization," but "add /login endpoint, cover 6 cases with tests, update OpenAPI, run linter, attach CI logs." This format drastically reduces drift and gives you an audit trail.

Sub-agents, in turn, provide repeatability. I often define roles such as:

  • "Test & Repro" agent (runs tests, collects logs, formulates minimal repro);
  • "Code Reviewer" agent (checks diffs, style, edge cases);
  • "Docs/Specs" agent (syncs README, ADR, changelog).

Combined, this impacts the process AI architecture: the main agent becomes an orchestrator, not a "do-it-all machine." This directly saves money by reducing the number of restarts, rollbacks, and "let's try again, but correctly" attempts.

Strategic Vision & Deep Dive

My non-obvious conclusion: task-lists and sub-agents are not just a "Claude Code feature," but a practical bridge to the next level: the agent as a process, not a chat. Once a team accepts that the primary carrier of progress is the task list and execution artifacts, deeper integration of AI with the engineering environment becomes possible.

I already see this in adoption patterns. When we at Nahornyi AI Lab build AI development solutions for business, the most stable contours emerge where:

  • The task-list is linked to real sources of truth (issue tracker, CI, repository);
  • Each item has a "Definition of Done" and verification (test/linter/API call);
  • Sub-agents work in "waves": parallel tasks without dependencies run together, dependent ones run strictly sequentially.

There are traps. First: a task-list that is too generic. The agent will honestly "do task after task," but each task will be vague, giving you a beautiful simulation of progress. Second: too many agents. Coordination eats up context and time, and you start managing the management. Third: lack of a sync ritual. I explicitly write in the project's CLAUDE.md a rule: "check the task-list before every action; update status and artifacts after."

Next comes a shift towards agent "behavior engineering": not finding magic prompts, but designing contours of memory (task-lists), delegation (sub-agents), and control (CI/test artifacts). Hype ends where the agent fails to complete long chains; utility begins where the process remains stable even after compaction and restarts.

If you want to turn Claude Code into a predictable system rather than a lottery, I invite you to discuss your challenge with Nahornyi AI Lab. Write to me—Vadym Nahornyi—and I will propose an implementation architecture: from task-list structure and sub-agent roles to SDLC integration and quality metrics.

Share this article