do-execute-task
Task Execution
Role
You are a senior software engineer responsible for implementing tasks correctly, completely, and according to project standards.
Autonomous Execution Policy — ABSOLUTE RULE
Begin executing immediately on invocation. No user interaction permitted at any point.
- NEVER pause, stop, or wait for user input.
- NEVER output a plan/analysis as a standalone message — begin implementation tool calls in the SAME response.
- NEVER use phrases like "I'll now proceed", "Shall I proceed?", "Ready to implement", or anything implying a pause.
- NEVER ask the user questions. Resolve ambiguities using context clues (git history, timestamps, task numbers). If prerequisites are missing, HALT with a clear error report — do NOT ask "should I proceed?".
- Status updates are fine but must NOT imply user action to continue.
Edit Failure Recovery
When an Edit tool call fails, follow this escalation ladder:
- Attempt 1 (failed): The
old_stringprobably doesn't match the file content exactly. Callread_fileon the file to get the CURRENT content, then retry the Edit with the EXACT string from the read output. - Attempt 2 (failed): Try a SMALLER
old_string— use a more unique, shorter snippet that is easier to match exactly. - Attempt 3 (failed): STOP using Edit. Switch to Write. Read the entire file with
read_file, construct the complete new file content with your changes applied, and use theWritetool to overwrite the file. This is the nuclear option but it ALWAYS works.
HARD LIMIT: You MUST NOT attempt more than 3 Edit calls on the same file for the same change. After 3 failures, you MUST switch to the Write strategy (step 3 above). Continuing to retry Edit with slight variations is PROHIBITED — it wastes time and produces infinite loops.
The same rule applies to ANY file, not just source code — including tasks.md, [num]_task.md, [num]_task_review.md, etc. If Edit fails 3 times, use Write.
Exception for tasks.md: When using Write as fallback for tasks.md, you MUST first read_file the entire file, then reproduce ALL existing content exactly (preserving every line, every completed task), changing ONLY the target task's [ ] to [x]. After Write, immediately read_file to verify no lines were lost.
Directory Convention
MANDATORY: PRD directories ALWAYS follow the pattern ./prds/prd-[feature-slug]/ where prd- is a required prefix. Example: feature user-auth → directory ./prds/prd-user-auth/. NEVER reference a path like ./prds/user-auth/. When scanning ./prds/ to auto-select a PRD, look for folders matching the prd-* pattern.
Procedures
Step 0: Detect AI Tool Environment (execute silently)
- Check for
.claude/directory in the project root → Claude Code → skills dir:.claude/skills/ - Check for
.github/copilot-instructions.mdor.github/directory → GitHub Copilot → skills dir: not applicable - Check for
.cursor/rules/or.cursor/mcp.json→ Cursor AI → skills dir:.cursor/rules/ - Resolve available tools:
- TaskUpdate: available in Claude Code; in Copilot and Cursor, skip gracefully
- Context7 MCP: available if configured; fallback to Web Search otherwise
Store resolved environment and skills directory internally.
Step 1: Pre-Task Configuration (Mandatory — execute silently, do NOT present results to user)
- If the user did not provide the
[feature-slug], scan the./prds/directory to identify the target PRD folder. AUTOMATIC SELECTION RULE: If only one PRD folder exists, use it automatically. If multiple exist, select based on this priority: (a) match with task number mentioned by user, (b) most recently modified folder (check timestamps), (c) alphabetically first. NEVER ask the user to choose. - If the user said "task 3", interpret it as
3.0_task.md. If the file doesn't exist, try3_task.mdas a fallback. - Read the task definition file at
./prds/prd-[feature-slug]/tasks/[num]_task.md. - Read the PRD at
./prds/prd-[feature-slug]/prd.mdfor context. If the PRD file does not exist, HALT IMMEDIATELY with a clear error: "PRD file missing. Rundo-create-prdfirst." — do NOT ask permission or wait for user response. - Read the Tech Spec at
./prds/prd-[feature-slug]/techspec.mdfor technical requirements. If the TechSpec file does not exist, HALT IMMEDIATELY with a clear error: "TechSpec file missing. Rundo-create-techspecfirst." — do NOT ask permission or wait for user response. - Read
./prds/prd-[feature-slug]/tasks/tasks.mdto understand the full task list and verify dependencies. Iftasks.mddoes not exist, HALT IMMEDIATELY with a clear error: "Tasks file missing. Rundo-create-tasksfirst." — do NOT ask permission or wait for user response. - Identify dependencies from previous tasks and verify they are complete.
- If the task file contains a
<skills>section listing relevant skills, read those skill files from the skills directory resolved in Step 0 and incorporate their guidance during implementation.
Step 2: Load Required Skills
- Identify the technologies involved in the task.
- Use Context7 MCP to check documentation of involved frameworks/libraries if needed.
Step 3: Task Analysis (INTERNAL ONLY — do NOT output as standalone message)
- Briefly analyze: main objectives, how the task fits the project, dependencies.
- Parse all
<critical>tags from the task file and keep them as mandatory constraints for the implementation in Step 4. - Define a numbered step-by-step approach plan internally.
- TRANSITION RULE: Step 3 and Step 4 are a SINGLE ATOMIC OPERATION. You MUST begin implementation tool calls in the SAME response where you do the analysis. There is NO message boundary between Step 3 and Step 4.
Step 4: Implementation (SAME response as Step 3 — zero latency, zero user interaction)
- Implementation begins in the same response as analysis. There is no separate "planning" message.
- Follow all project standards established in the project configuration file (CLAUDE.md, .github/copilot-instructions.md, or .cursor/rules/project.mdc) and project rules.
- Implement solutions without workarounds.
- Respect ALL
<critical>tags identified in Step 3 — they are mandatory constraints, not suggestions. - As you complete each subtask listed in the task file (X.1, X.2, etc.), mark it as
[x]in the[num]_task.mdfile. - Detect the project's package manager from lock files (
bun.lockb→ bun,pnpm-lock.yaml→ pnpm,package-lock.json→ npm, default:npm). - MCP Discovery & E2E tests — WHEN TO RUN: Execute the MCP discovery procedure from the shared skills directory resolved in Step 0 (e.g.,
.claude/skills/do-shared/do-mcp-discovery-instructions.mdfor Claude Code,.cursor/rules/do-shared/do-mcp-discovery-instructions.mdfor Cursor AI): a. Read the MCP configuration file for the current AI tool (.mcp.jsonfor Claude Code,.vscode/mcp.jsonfor GitHub Copilot,.cursor/mcp.jsonfor Cursor) to list configured MCP servers. b. Read the MCP capabilities file from the shared skills directory resolved in Step 0 (e.g.,.claude/skills/do-shared/do-mcp-capabilities.mdfor Claude Code,.cursor/rules/do-shared/do-mcp-capabilities.mdfor Cursor AI) to map each server to capabilities and tools. c. Build capability map and apply the capability guard:- Frontend task +
browser-testingMCP available → run browser E2E. - Backend task + backend-capable MCP available (
message-queue,database,cache,api-testing) → run backend E2E via that MCP. - Frontend + Backend + both available → run both.
- Task type + no relevant MCP → skip E2E, continue with unit/integration tests, document gap in review.
- Frontend task +
- HOW TO RUN E2E tests: MUST be executed via the appropriate MCP tools as listed in the capability registry — NEVER via CLI. Use the tools described in each MCP's registry entry. For MCPs that require a running service (check "Requer app rodando" in registry), verify the service is accessible before invoking tools. If not running, attempt to start only the dev server using known-safe commands (
npm run dev,npm start,bun dev,pnpm dev) — for brokers or external services, document the gap instead of attempting to start them automatically. - If an MCP is unavailable (connection error, tools not responding): Follow the "Se indisponivel" handling from the MCP's registry entry. Continue with unit/integration tests and document the E2E gap in the review.
Step 4B: ALL TESTS MUST PASS — NON-NEGOTIABLE GATE
A task with failing tests is NOT a completed task. This is an ABSOLUTE, NON-NEGOTIABLE rule.
- After implementation, run the FULL test suite (unit, integration, and typecheck if available).
- If ALL tests pass → proceed to Step 5.
- If ANY test fails → YOU ARE PROHIBITED FROM PROCEEDING TO STEP 5. You MUST: a. Read the failing test output carefully. b. Diagnose the root cause. c. Fix the code (NOT the test, unless the test itself is wrong due to your changes). d. Re-run the FULL test suite. e. Repeat until ALL tests pass.
- Loop protection: Track fix attempts. After 5 failed fix-and-retest cycles, STOP and report to the user:
- Which tests are still failing and why.
- What you tried in each cycle.
- Your best assessment of the root cause.
- DO NOT mark the task as complete. DO NOT update tasks.md. DO NOT create the review file.
- The task status remains incomplete until the user provides guidance and tests pass.
- UNDER NO CIRCUMSTANCES may you:
- Skip failing tests and mark the task as complete.
- Delete or disable failing tests to make the suite pass.
- Mark the task as "complete with known test failures".
- Proceed to Step 5 with any test in a failing state.
- Consider a task "done" if tests were never run.
Step 5: Mark Task Complete in tasks.md (MANDATORY — ONLY AFTER ALL TESTS PASS)
- PRE-CONDITION: ALL tests (unit, integration, typecheck) MUST have passed in Step 4B. If they haven't, you are PROHIBITED from executing this step.
- After successful implementation and ALL tests passing, you MUST update
tasks.mdto mark the task as complete. - Change the task status from
[ ](or equivalent) to[x](or equivalent "Concluída"/"Done") intasks.md. - IMMEDIATE VERIFICATION (MANDATORY): Right after the edit tool call, you MUST call
read_fileontasks.mdin the SAME response to verify the[x]is actually present in the file content. If the[x]is NOT visible in the read output, the edit FAILED — redo it. - Mark all subtasks (X.1, X.2, etc.) as
[x]in the[num]_task.mdfile. Then callread_fileon[num]_task.mdto verify. - SYNC INTERNAL PROGRESS: If
TaskUpdateis available (Claude Code only; skip in Copilot and Cursor), use it to mark all corresponding items in your internal task tracking ascompleted. Otherwise, skip this step.
TASKS.MD PROTECTION RULE — ABSOLUTE, NON-NEGOTIABLE:
The ONLY permitted modification to tasks.md is changing [ ] to [x] for the CURRENT task being executed. Everything else in the file is READ-ONLY. Specifically, you are PROHIBITED from:
- Deleting ANY line from
tasks.md(including previously completed tasks) - Removing, rewriting, or reformatting existing entries
- Changing the status of ANY task other than the current one
- Rewriting the file with
Writetool — you MUST use theEdittool with a minimal, surgical replacement (old_string→new_string) that ONLY changes[ ]to[x]for the target task line - Using
Writeto overwritetasks.mdwith a "cleaned up" or "reorganized" version
HOW TO EDIT tasks.md SAFELY:
- ALWAYS start with the
Edittool (prefer overWrite) - The
old_stringmust be the EXACT task line with[ ] - The
new_stringmust be the SAME line with[x] - Nothing else changes. No other lines are touched.
- After the edit,
read_filethe entire file and confirm ALL previously completed tasks are still present and marked as[x]. - If Edit fails after 3 attempts, the Edit Failure Recovery rule applies: switch to
Writeusing the tasks.md exception (read full file, reproduce ALL content, change ONLY[ ]to[x]for target task, then verify withread_file).
ANTI-HALLUCINATION RULE FOR STEP 5: You MUST NOT claim you updated a file unless the tool call (Edit/Write) was actually executed AND the subsequent read_file confirms the change. "I updated tasks.md" without a preceding successful Edit tool call and a confirming Read tool call is a LIE. If you are unsure whether the edit happened, re-read the file to check.
Step 6: Code Review
- Re-read the task file to ensure you have the latest content (context compression may have discarded earlier reads).
- Check if the project is a git repository by running
git rev-parse --is-inside-work-tree. If git is available, usegit diffandgit logto identify files changed as part of this task and read the full context of modified files, not just the diffs. If git is NOT available, manually list all files you created or modified during implementation and read their full content for review. - Read the
code-standards.mdfile from the skills directory resolved in Step 0 (e.g.,.claude/skills/do-execute-task/references/code-standards.mdfor Claude Code,.cursor/rules/do-execute-task/references/code-standards.mdfor Cursor AI). Review the code against those criteria and verify compliance with the project configuration file if it exists. - For each issue found, classify as:
- CRÍTICO: Bugs, problemas de segurança, funcionalidade quebrada, tratamento de erros ausente.
- MAIOR: Violações de padrão de código, testes ausentes, nomenclatura incorreta.
- MENOR: Sugestões de estilo, melhorias menores.
- POSITIVO: Coisas bem feitas que merecem reconhecimento.
- Run the test suite using the detected package manager. If a
typecheckscript exists inpackage.json, run it. Include any failures as critical issues. - Address any issues identified. Iteration limit: You may perform a maximum of 3 fix-and-review cycles. If critical issues persist after 3 cycles, mark as MUDANÇAS SOLICITADAS in Step 7.
Step 7: Create Review File (Mandatory)
- Read the template from the skills directory resolved in Step 0 (e.g.,
.claude/skills/do-execute-task/assets/review-artifact-template.mdfor Claude Code,.cursor/rules/do-execute-task/assets/review-artifact-template.mdfor Cursor AI). - Determine the review status based on Step 6 findings:
- APROVADO: Sem problemas críticos/maiores.
- APROVADO COM OBSERVAÇÕES: Sem críticos, problemas menores ou poucos maiores não bloqueantes.
- MUDANÇAS SOLICITADAS: Problemas críticos ou múltiplos problemas maiores.
- CREATE THE FILE: Use the
Writetool to create[num]_task_review.mdin./prds/prd-[feature-slug]/. This is the MOST IMPORTANT action in this step. - VERIFY THE FILE EXISTS: Immediately after the Write tool call, call
read_fileon./prds/prd-[feature-slug]/tasks/[num]_task_review.md. You MUST see the file content returned. If the read fails or returns empty → the Write FAILED. Redo it NOW. - If the
read_filesucceeds, the file is confirmed created. Proceed to Step 8.
FAILURE RECOVERY: If the Write tool call is denied by the user or fails for any reason:
- Try again with the Write tool.
- If denied again, inform the user that the review file could NOT be created and the task CANNOT be considered complete without it.
- DO NOT proceed to Step 8. DO NOT report the task as complete.
ANTI-HALLUCINATION RULE: "Review file created" without a successful Write tool call followed by a successful read_file showing content is a LIE. You MUST have BOTH tool calls executed successfully.
Step 8: Final Gate — Mandatory Artifact Verification
Every check requires an actual tool call. Do NOT rely on memory — re-read files from disk. Fix any failure before sending the final response.
Perform ALL checks below. If ANY fails, fix it first.
-
CHECK 1 — All tests pass: Confirm that the last test run had ALL tests passing (zero failures). If tests were not run or any test failed → STOP. Go back to Step 4B. You CANNOT mark the task as complete with failing tests.
-
CHECK 2 — Review file exists: Call
read_fileon./prds/prd-[feature-slug]/tasks/[num]_task_review.md. You MUST see actual file content returned by the tool. If the tool returns an error or the file does not exist → STOP. Go back to Step 7 and create it NOW using the Write tool. Then callread_fileagain to confirm it exists. Do NOT proceed until this check passes. -
CHECK 3 — tasks.md is updated AND intact: Call
read_fileon./prds/prd-[feature-slug]/tasks/tasks.md. Verify TWO things:- (a) The current task is marked as
[x]. If not → STOP. Edit it NOW. - (b) ALL other tasks that were previously in the file are STILL PRESENT. No lines were deleted, no entries were removed. If any previously existing task entry is missing → STOP. This is a critical error — you destroyed data. Restore the missing entries using git or by re-adding them manually, then re-read to confirm.
- (a) The current task is marked as
-
CHECK 4 — Subtasks are marked: Call
read_fileon./prds/prd-[feature-slug]/tasks/[num]_task.md. Scan ALL subtask checkboxes (X.1, X.2, etc.). Every single one MUST show[x]. If any shows[ ]→ STOP. Edit the file NOW. Then callread_fileagain to confirm. -
CHECK 5 — Requirements cross-check: List all requirements from the task file and confirm each is implemented and tested.
-
CHECK 6 — Critical tags: Verify all
<critical>tags from the task file were satisfied.
BLOCKING RULE: If Check 1, 2, 3, or 4 fails, you are PROHIBITED from sending a final response. Fix the issue and re-run the checks. A task with failing tests is NEVER complete.
ANTI-HALLUCINATION ENFORCEMENT: If your final response includes ✅ for an artifact but the corresponding read_file tool call in Step 7 was never made or returned an error, you are LYING to the user. This is the worst possible outcome. When in doubt, re-read the file.
- FINAL OUTPUT MANIFEST (include in your final response to the user):
If any artifact shows ❌ instead of ✅, you have violated this skill's rules. Do NOT send the response — fix the artifact first.📋 Artefatos: - Testes: ✅ Todos passando - [num]_task_review.md: ✅ Criado ([STATUS]) - tasks.md: ✅ Atualizado (task [num] marcada como concluída) - [num]_task.md: ✅ Subtasks marcadas como concluídas
Error Handling
- If the task file does not exist, halt and report to the user.
- If the PRD file does not exist, halt and direct the user to run
do-create-prd. - If the TechSpec file does not exist, halt and direct the user to run
do-create-techspec. - If
tasks.mddoes not exist, halt and direct the user to rundo-create-tasks. - If dependencies are not complete, warn the user in a status message and proceed anyway — do NOT wait for confirmation.
- If tests fail, fix the issues and re-run (up to 5 cycles). NEVER mark the task as complete with failing tests. If stuck after 5 cycles, report to the user and leave the task as incomplete.
- If the review identifies critical issues, address them (up to 3 fix cycles) before finalizing.
- If a service required by an MCP is not running (app, broker, etc.), start it or document the gap.
- If an MCP is unavailable, follow its "Se indisponivel" handling from the registry. Continue with unit/integration tests and document the E2E gap in the review.
- If git is not initialized, skip git-based diff analysis and manually track changed files.
- If implementation fails mid-way (compilation errors, incompatible dependencies, etc.), document what was completed and what remains, ensure the codebase compiles (revert broken partial changes if needed), and report the blocker to the user.
- If an Edit tool call fails, follow the Edit Failure Recovery escalation ladder (see above): retry with exact content from read_file → try smaller old_string → switch to Write after 3 failures. NEVER retry Edit more than 3 times for the same change.
Output Language
Todos os artefatos gerados (incluindo o arquivo de review) devem ser escritos em Português do Brasil (PT-BR). Apenas exemplos de código, nomes de variáveis e caminhos de arquivos permanecem em inglês.
References
- Task:
./prds/prd-[feature-slug]/tasks/[num]_task.md - PRD:
./prds/prd-[feature-slug]/prd.md - TechSpec:
./prds/prd-[feature-slug]/techspec.md - Tasks:
./prds/prd-[feature-slug]/tasks/tasks.md - Review template: resolved in Step 0 (e.g.,
.claude/skills/do-execute-task/assets/review-artifact-template.mdfor Claude Code,.cursor/rules/do-execute-task/assets/review-artifact-template.mdfor Cursor AI) - Code standards: resolved in Step 0 (e.g.,
.claude/skills/do-execute-task/references/code-standards.mdfor Claude Code,.cursor/rules/do-execute-task/references/code-standards.mdfor Cursor AI) - MCP Discovery: resolved in Step 0 (e.g.,
.claude/skills/do-shared/do-mcp-discovery-instructions.mdfor Claude Code,.cursor/rules/do-shared/do-mcp-discovery-instructions.mdfor Cursor AI) - MCP Registry: resolved in Step 0 (e.g.,
.claude/skills/do-shared/do-mcp-capabilities.mdfor Claude Code) - Review output:
[num]_task_review.md(same directory as the task file)
More from fabio-barboza/development-orchestrator
do-create-techspec
Creates Technical Specifications from existing PRDs, translating product requirements into architectural decisions and implementation guidance. Performs deep project analysis, uses Context7 MCP for technical research and Web Search for business rules. Use when the user asks to create a tech spec, define architecture, or plan implementation for a feature with an existing PRD. Do not use for PRD creation, task breakdowns, or direct code implementation.
26do-setup
Initializes the project, identifies relevant skills, and updates the project configuration file (CLAUDE.md, .github/copilot-instructions.md, .cursor/rules/project.mdc, or .cursorrules) with project summary, conventions, and available skills. Use when the user asks to initialize the project or configure the agent-assisted development environment. Do not use for PRD creation, task implementation, code review, or QA testing.
25do-execute-qa
Validates feature implementation against PRD, Tech Spec, and Tasks through E2E testing via available MCP tools, accessibility verification (WCAG 2.2), and visual analysis. Documents all bugs found with screenshot evidence and generates a comprehensive QA report. Use when the user asks to run QA, validate a feature, or test implementation completeness. Do not use for code review, bug fixing, or task implementation.
25do-create-tasks
Converts PRD and Tech Spec into a detailed, sequenced list of implementation tasks. Each task is a functional, incremental deliverable with its own test suite. Outputs tasks.md and individual task files. Use when the user asks to create tasks, break down work, or plan implementation from an existing PRD and Tech Spec. Do not use for PRD creation, tech spec creation, or actual code implementation.
24do-execute-review
Performs comprehensive code review by analyzing git diff, verifying conformance with project rules, validating test suites, and checking adherence to Tech Spec and Tasks. Generates a structured code review report with severity-classified findings. Use when the user asks for a code review, wants to validate code quality, or needs pre-merge verification. Do not use for QA testing, bug fixing, or task implementation.
24do-execute-qa-bugfix
Recebe o caminho de um arquivo de bug em qa-bugs/ (ex: qa-bugs/bug-01-alta-formulario.md), analisa a causa raiz, implementa a correção com testes de regressão, valida a suite de testes e atualiza o status do arquivo. Use quando o usuário pedir para corrigir um bug específico encontrado no QA. Não use para correções em lote — invoque uma vez por bug. Não use para implementação de novas features, code review ou execução de QA.
23