/ai-cli-task cancel — Cancel Task Module
Cancel a task module, stopping any active auto loop and optionally cleaning up the git worktree.
Usage
code
/ai-cli-task cancel <task_module_path> [--reason "..."] [--cleanup]
Arguments
- •task_module (required): path to task module directory
- •--reason (optional): cancellation reason, recorded in
.index.mdbody - •--cleanup (optional): also remove the git worktree and delete the task branch
Execution Steps
- •Read
.index.md— get current status - •Stop auto if running:
- •Call
GET /api/task-auto/lookup?taskDir=<task_module_path>to find the session running this task's auto loop - •If found (200): call
DELETE /api/sessions/<session_name>/task-auto - •If not found (404): no auto loop running, skip
- •Delete
.auto-signalfile if exists - •Delete
.auto-stopfile if exists - •Delete
.lockfile if exists (release any stale lock from the cancelled session)
- •Call
- •If uncommitted changes exist, git commit snapshot:
-- ai-cli-task(<module>):cancel pre-cancel snapshot - •Update
.index.md:- •Set
statustocancelled - •Update
updatedtimestamp - •Append cancellation reason to body (if provided)
- •Set
- •Git commit:
-- ai-cli-task(<module>):cancel user cancelled - •If
--cleanup:- •Remove worktree:
git worktree remove .worktrees/task-<module> - •Delete branch:
git branch -D task/<module>(only if fully merged or with--force)
- •Remove worktree:
- •Report cancellation result
State Transitions
Any non-terminal status → cancelled. Terminal statuses (complete, cancelled) → REJECT.
Notes
- •Cancel is rejected on terminal statuses:
complete(use a separate workflow to reopen) andcancelled(already terminal) - •If the task has uncommitted code changes in a worktree,
--cleanupwill warn before deleting - •Without
--cleanup, the branch and worktree are preserved for reference - •A cancelled task can be referenced by
reportfor documentation purposes