with one click
granary-execute-task
// Execute an assigned granary task as a sub-agent. Use when you receive a task ID to complete.
// Execute an assigned granary task as a sub-agent. Use when you receive a task ID to complete.
Set up granary in a new project. Use when asked to initialize granary, install it, or get started with task management.
Plan and organize multi-project initiatives or significant, substantial projects. Use when work spans multiple services, repositories, or has natural project boundaries.
Orchestrate sub-agents and coordinate multi-agent workflows with granary. Use when delegating tasks, spawning workers, or managing parallel execution.
Plan and organize work into granary projects and tasks. Use when breaking down a feature, creating tasks, or setting up dependencies.
| name | granary-execute-task |
| description | Execute an assigned granary task as a sub-agent. Use when you receive a task ID to complete. |
You are a sub-agent spawned by an orchestrator to complete a specific task. Your responsibility is to:
You do NOT coordinate other agents. You do the actual work.
First, use granary handoff to retrieve full context for your task:
granary handoff --tasks <task-id>
This returns:
Read this context carefully. The planner has done thorough research and provided everything you need. The handoff context is your primary source of truth.
The handoff includes:
| Section | Contains |
|---|---|
| Task Details | Goal, context, requirements, acceptance criteria |
| Files to Modify | Exact file paths with line numbers |
| Implementation Details | Code examples, patterns, function signatures |
| Steering Files | Project conventions, existing patterns, research notes |
If the handoff mentions specific files like src/services/user.rs:45-67, read those files to understand the existing patterns before making changes.
If you need the raw task data:
granary show <task-id>
# or
granary task <task-id>
Use this to double-check task metadata (priority, dependencies, status).
Mark the task as in-progress:
granary task <task-id> start
If working in a multi-agent environment, claim with a lease to prevent conflicts:
granary task <task-id> start --lease 30
The lease (in minutes) ensures no other agent claims this task while you work.
This is your main responsibility. Implement whatever the task description specifies:
Add comments as you work to maintain visibility for the orchestrator:
granary task <task-id> comments create "Started implementing the login form"
granary task <task-id> comments create "Completed form validation, now adding API integration" --kind progress
Comment kinds: note, progress, decision, blocker
When you have successfully completed the task:
granary task <task-id> done --comment "Implemented login form with validation and API integration"
Important: Only mark done when the task is truly complete according to its acceptance criteria.
If you cannot continue due to external factors:
granary task <task-id> block --reason "Waiting for API credentials from ops team"
This signals to the orchestrator that this task needs attention.
If you cannot complete the task for any reason, release it so others can pick it up:
granary task <task-id> release
Then report back to the orchestrator with what went wrong.
If working in parallel with other agents:
# Extend lease for long-running tasks
granary task <task-id> heartbeat --lease 30
# Check if task is still yours
granary task <task-id>
Exit codes to watch for:
4 = Conflict (task claimed by another agent)5 = Blocked (dependencies not met)As a sub-agent, your workflow is:
granary handoff --tasks <id> to get full task details with steeringsrc/foo.rs:45-67)granary task <id> startgranary task <id> comments create "..."granary task <id> done or granary task <id> blockRemember: The planner has done thorough research. Your handoff context contains file paths, implementation details, and code patterns. Trust this context—it's specifically prepared for you to execute without additional exploration.