Delegate implementation tasks to Cursor CLI (Composer 2) in headless mode. Use when the user says "cursor", "composer", "cursorに実装させて", "cursorで実装", "delegate to cursor", or wants to offload coding work to Cursor's agent.
Claude Code handles planning, git operations, and review. Cursor handles coding (tests + implementation).
Cursor automatically reads and applies:
Do NOT re-inject project constraints into the prompt. Cursor already has them.
| Owner | Work |
|---|---|
| Claude Code | Identify the problem, decide what to fix, create branch |
| Cursor | Write tests + implementation independently using TDD. No git operations |
| Claude Code | Verify changes with git diff --stat, run tests, commit, review, push, create PR |
git checkout -- <file> for individual files# Create branch (follow project naming conventions)
git checkout <base-branch> && git checkout -b <branch-name>
# Verify clean working tree
git status --short # should be empty
Write task-level instructions. Do NOT write exact code diffs. Do NOT repeat project rules. Keep it concise.
## Task
[What needs to be done — goal level, no code snippets]
## Background
[Why this fix is needed]
## Target files (reference)
[Main files to change. Cursor may add more if needed]
## Test requirements
[What to test. Let Cursor decide how to write the tests]
## Implementation instructions
Implement using TDD:
1. Write tests
2. Confirm tests fail
3. Write implementation code
4. Confirm tests pass
5. Report list of changed files
## Forbidden
- git commit / push / branch operations
- Adding or updating dependencies
- Running dev server / build / deploy
cursor agent -p --trust \
--workspace "<project-dir>" \
--model composer-2 \
"<prompt>"
--model composer-2 unless user specifies otherwise--yolo. Use default approval-based execution# Check change scope
git diff --stat
# → Ensure no files outside the task scope were changed
# Run tests (use project's test command)
<project-test-command>
# If OK, commit
git add <changed-files>
git commit -m "<message>"
If unexpected files were changed:
# 1. Revert individual files
git checkout -- <unexpected-file>
# 2. Revert multiple unexpected files
git diff --name-only | grep -v '<expected-file>' | xargs git checkout --
# 3. Last resort (only if working tree was clean before delegation)
git checkout -- .
Follow the project's review workflow (e.g., spec review + quality review via subagents).
# Follow-up instructions (fixes, etc.)
cursor agent -p --trust \
--workspace "<project-dir>" \
--continue \
"<follow-up instructions>"
# List sessions
cursor agent ls
| Flag | Purpose |
|---|---|
-p | Headless output (required for CLI execution) |
--trust | Trust workspace (required for headless mode) |
--workspace <path> | Working directory |
--model <model> | Model selection (default: composer-2) |
--continue | Continue previous session |
--resume <chatId> | Resume specific session |