This guide instructs an agent how to investigate a user request, decompose it into an ordered set
of independent tasks, and populate <workspace-root>/tasks/ for orchestrate-batch. It can also
be copied and adapted as <workspace-root>/tasks/README.md when a project needs these rules next
to its local queue.
When this guide is copied to <workspace-root>/tasks/README.md, the batch runner allows and ignores
that copy during task discovery. It does not automatically pass queue documentation to the
executor or reviewer. Therefore, every tasks/NNN.txt file must be self-contained: it must include
the complete original planning request, all material constraints, and the expected outcome.
Before applying this guide, determine the target workspace's local rules using the checklist at the end. Do not place information that agents must see only in a queue README. Repeat such information in every affected task file or establish it in the repository's standard instructions.
tasks/is the ordered local queue of pending tasks.- Task files are named
NNN.txt, whereNNNis an increasing numeric identifier, usually at least three digits:001.txt,002.txt,003.txt, and so on. tasks/done/contains successfully completed tasks.tasks/README.md,tasks/.batch.lock, and the contents oftasks/done/are not active queue entries.- The entire
tasks/directory is local runtime state, is excluded from Git, and must not be added to the index. .batch.lockis reserved for the batch runner. Do not create, remove, or modify it manually. If the batch runner reports that the queue is locked, do not bypass the lock.
- Active files are processed strictly in ascending numeric identifier order.
- One file describes one independent, verifiable task with a complete outcome.
- A task may depend only on tasks with lower identifiers. State every dependency and the expected state after it explicitly.
- Every task must leave the project in a coherent, verifiable state.
- Separate changes that have different contracts, risks, verification methods, or independent rollback boundaries.
- Keep related producers and consumers in the same task when the intermediate state does not compile, violates a contract, or creates invalid runtime semantics.
- Do not split work more finely than required for independence, verification, and safe rollback.
Prefer a normal task size of
M-L. SeveralStasks should normally be combined with each other or attached to a semantically relatedM-Ltask unless doing so mixes distinct contracts, risks, verification methods, or rollback boundaries. - Do not create a task for work that is already complete or fully covered by an existing file. Confirm this against the current code and history first.
- Do not rewrite or renumber existing files without an explicit decision from the queue owner.
- Current code and current Git history are the source of truth. Old discussions, plans, and reports provide context but do not replace verification of the current state.
- Create an active task file only after the complete mandatory outcome is known to be feasible and supported by current code, documentation, an available dependency contract, a local experiment, or an explicit authoritative decision.
- Do not defer mandatory TODOs, blockers, open questions, external specifications, safety confirmation, or discovery into a task when implementation cannot start or finish without resolving them. Resolve the uncertainty first; if that is impossible, do not create the task.
- A task does not need to prescribe a specific implementation when the target behavior is
already proven achievable. State the verifiable contract and constraints, then let the
planworkflow select the concrete approach. - A task may require changes only to the project whose root contains that
tasks/directory. Every modified file, local commit, migration, configuration change, and test must belong to that project root. - Other repositories and external dependencies may appear only as existing contracts, constraints, or read-only evidence. Do not include changes to them in the scope, implementation steps, verification requirements, or completion criteria of the current task.
If the requested outcome requires changing another project, do not combine that work into the current task. Arrange and complete it separately in that project's own workspace and queue. Create the current project's task only when it can rely on the resulting external contract as already available and verified.
Before creating each file, investigate the proposed scope of that specific task:
- Find the definitions of affected types, APIs, schemas, configuration, and runtime state.
- Find all material callers, producers, consumers, constructors, handlers, subscriptions, and public re-exports.
- Find application wiring, dependency injection, routes, persistence paths, feature-gated paths, and platform-specific paths.
- Inspect relevant history with
git log,git show, andgit blamewhen the current code is ambiguous without historical context. - Find existing unit, integration, and end-to-end tests and identify coverage gaps.
- Check whether earlier tasks or commits have already implemented the work fully or partially.
- Record current and target semantics, not only a list of files and types.
- Find repository-approved formatting, static analysis, build, and test commands in
AGENTS.md,CLAUDE.md, documentation, CI, and build scripts. Do not invent commands.
Before writing each new NNN.txt, establish that the task can be completed in full in the expected
workspace state:
- Every mandatory API, firmware or protocol contract, data source, permission, and infrastructure capability already exists or is the verifiable guaranteed result of a lower-numbered task.
- At least one technically valid implementation path exists for every critical transition and does not rely on an unverified assumption.
- Mandatory verification commands and completion criteria are achievable in the permitted environment.
- The best implementation approach may remain undecided, but the feasibility of the mandatory result may not.
Do not create an active task that asks the plan or implementation workflow to:
- obtain an unknown external specification or contract first;
- discover whether a required API, command, or primitive exists;
- confirm the safety of a mandatory operation;
- perform discovery whose result determines the task's scope or whether completion is possible;
- stop as
blockedwhen a mandatory prerequisite cannot be found.
Resolve that uncertainty before queueing the task. If local evidence is insufficient, report the
gap to the queue owner and do not create NNN.txt. Do not hide unproven feasibility in Blockers,
Open questions, TODO, the first implementation step, or a conditional completion criterion.
Not selecting an implementation in advance is acceptable. When the outcome is demonstrably
achievable in more than one way, state the required behavior, constraints, and evidence, and let
the plan workflow choose the concrete solution from the current code.
For the affected behavior, consider every applicable question:
- Who owns the authoritative state, and who may modify it?
- Is the interaction a command, request, response, event, or published state?
- Which identifiers, keys, tags, or correlation IDs distinguish independent data flows?
- In what order are producers, consumers, and subscriptions created?
- Which ordering, delivery, retry, timeout, and error propagation guarantees must be preserved?
- What happens when data, a subscriber, a responder, or an external dependency is absent?
- Are default, reset, sticky, or tombstone semantics needed to prevent stale state?
- How does the system behave under queue overflow, backpressure, and partial failure?
- Which schema, serialization, migration, and backward compatibility constraints apply?
- How does the change affect performance, memory, cloning, batching, and concurrency?
- Which security, privacy, and permission boundaries may be affected?
Do not include inapplicable items merely to fill the checklist. If important behavior is unknown, investigate it before creating the task. If mandatory feasibility cannot be established locally, report the gap to the queue owner and do not create an active task file.
Combine changes when at least one of the following conditions applies:
- The new contract cannot have a correct producer without migrating its consumer at the same time.
- Separate commits would require a one-off compatibility adapter.
- Both parts rely on the same data, type, or state-contract migration.
- Only a combined change can remove the completed legacy wiring.
- An intermediate task cannot be verified correctly on its own.
Do not combine changes merely because their files are adjacent. Different guarantees, rollback boundaries, migrations, owners, and substantially different test sets should usually remain separate tasks.
All else being equal, prefer fewer substantial M-L tasks over a chain of small S tasks. A
standalone S task is justified only when it has independent value, can be verified independently,
and is separated from neighboring work by its contract, risk, or rollback boundary.
- Find the highest numeric identifier among
tasks/NNN.txtandtasks/done/NNN.txt. - Use the previous maximum plus one as the new identifier.
- If no task files exist, start with
001.txt. - Create only a new file. Do not change existing tasks without an explicit decision from the queue owner.
- If investigation shows that no work is required, do not create a file.
Every NNN.txt must be self-contained and contain the following sections or an equivalent
structure.
- Name the changed contract or completed behavior concisely, not merely the module.
- Describe the verifiable result that must exist after implementation.
- Explain why the change is required.
- List the functional scope.
- Identify the main sources of complexity and risk.
- Explicitly list adjacent changes that are outside the task.
- Verify that every path to be modified is inside the project root that owns this queue. Do not include changes to sibling repositories, dependency checkouts, or other external projects.
- Do not hide cleanup required for the integrity of the new contract behind scope boundaries.
- List the identifiers of required preceding tasks.
- Describe the expected code state after those tasks.
- Identify overlaps with other queue files and state the rule that prevents duplicate work.
- Write
nonewhen there are no dependencies.
- Provide concrete definitions and execution paths.
- List the identified callers, producers, consumers, and wiring edges.
- Describe existing error, data, ordering, and lifecycle semantics.
- Identify relevant tests and coverage gaps.
- Use current
path:linereferences when line numbers are known. - Separate verified facts from permissible implementation choices. Do not leave unresolved questions that determine whether the mandatory outcome is feasible.
- Describe the owner of the data, state, or event.
- Define the producer-consumer interaction.
- List the startup, ordering, delivery, reset, and error-handling guarantees that must be preserved.
- Define what constitutes valid absence of data and what constitutes an error.
- State compatibility and migration requirements.
- Include all mandatory user decisions, prohibitions, and selection criteria.
- Identify applicable local instructions and project profiles.
- State network, external-system, data, and environment constraints.
- Do not instruct agents to "evaluate", "investigate later", "obtain the contract", "confirm feasibility", or "return blocked if unavailable".
- If additional information is required to guarantee the complete result, the task is not ready and must not enter the active queue.
- List affected modules, APIs, schemas, migrations, configuration, and tests.
- For non-trivial logic, provide code anchors and short snippets or pseudocode that establish the intent and contract.
- Describe complete cleanup of legacy types, fields, routes, wiring, imports, and dead code.
- Add scoped search checks for entities that must disappear. The commands must not falsely match the task documentation itself.
This is not a ready-made PLAN.md. The file defines the original request and verifiable
requirements. The plan workflow creates the detailed plan after investigating the current
workspace again.
Describe the most useful practical set of portable automated tests and, when it helps define the scope, divide it into three categories:
- Without additional refactoring. Mandatory tests for new behavior and regression tests for the affected contract that must accompany the main implementation.
- With light refactoring. Tests that require a small helper, fake dependency, or pure handler. State explicitly whether they are included in the current task.
- With heavy refactoring. Valuable integration, load, or end-to-end tests that require separate infrastructure. They may be explicitly out of scope only when they are not required to prove completion of the current task. Do not record them as a TODO or blocker; create a separate task only after its feasibility has been established.
Tests should be self-contained and portable whenever practical: use in-memory state, inline
fixtures, mocks or fakes, and controlled temporary resources. Do not tie them to a personal
$HOME, absolute paths, sibling repositories, or preconfigured machine state unless objectively
necessary.
- List possible behavioral, API, data, integration, performance, and security regressions.
- For each material risk, state how it can be detected or verified.
- Provide verifiable conditions under which the task is genuinely complete.
- Define acceptable behavior during partial failure and dependency unavailability.
- Specify repository-approved formatter, linter or static analysis, build, and targeted test commands.
- Start with scoped checks and broaden the scope only when needed.
- Do not substitute manual verification for automated tests when a portable test is practical.
- State the expected local commit strategy when it is material to the task.
- Do not require a push unless the user explicitly requested one.
By default, for each active NNN.txt with the lowest identifier, orchestrate-batch:
- Wraps the exact file contents between
batch_task_prompt_beginandbatch_task_prompt_end, adds feasibility/reporting guidance, and passes the result as the user prompt to theplanworkflow. - Stops on any planning result other than an accepted successful result.
- After an accepted plan, starts the
implementworkflow with instructions to implementPLAN.md. - Stops on any implementation result other than an accepted successful result.
- After successful implementation, removes the tracked
PLAN.mdin a separate local commit. - When processing starts, removes a same-named previous copy from
tasks/done/. Only after complete success, removes that destination again if it was recreated and moves the original file fromtasks/totasks/done/if it still exists. - Continues with the next lowest identifier.
With --implement-only (alias --impl), the batch runner instead:
- Requires
PLAN.mdto be absent during batch preflight and throughout each task. - Wraps the exact task contents in implementation guidance and sends them directly to the
implementworkflow without creating or changingPLAN.md. - Preserves the orchestrator's complete reviewer revise loop.
- Skips plan creation and
PLAN.mdcleanup. - Moves the task to
tasks/done/only after accepted implementation.
The batch runner itself leaves the file in the root of tasks/ throughout planning and
implementation. After reading the planning prompt, it does not monitor later content changes. If
another process changes, moves, or removes the file, the batch continues. The batch runner does not
create attempt reports. Moving the completed file from tasks/ to tasks/done/ is exclusively the
batch runner's responsibility. Executors and reviewers must not move, remove, or rename queue
files.
The batch runner considers a task complete only when all requirements for the selected mode hold:
- In default mode, the
planworkflow completed with an accepted result. - The
implementworkflow completed with an accepted result. - All mandatory changes, tests, and cleanup were implemented.
- Checks required by repository instructions and project profiles were completed, or omissions were explicitly justified and accepted by the reviewer.
- Tracked workspace changes are in local commits, and the worktree satisfies the workflow contract.
- In default mode, the temporary
PLAN.mdwas removed and its removal was committed. - In implement-only mode, no
PLAN.mdexisted and no cleanup commit was required.
Before populating a target queue, determine and apply concrete project rules such as:
- Where to find
AGENTS.md,CLAUDE.md, architecture documentation, and build or test documentation. - Which project profiles and language-specific instructions apply.
- Which CI, build, and test commands are repository-approved.
- Which architectural invariants must be checked during decomposition.
- Which external systems are permitted or prohibited.
- Which branch, commit, and release conventions apply.
Do not turn the local section into a hidden source of requirements for agents. Material
task-specific requirements must appear directly in the corresponding NNN.txt.