Prompt Details
Model
Chat - (gpt-5.6)
Token size
2,794
Example input
[LARGE_CODING_TASK]: Build an AI-powered invoice processing feature that accepts PDF invoices, extracts vendor/invoice/amount/tax data, validates the extracted information, stores structured records, and exposes the results through an API and dashboard.
[CODEBASE_ARCHITECTURE_AND_REPOSITORY_STRUCTURE]: Backend: Python + FastAPI Frontend: React + TypeScript Database: PostgreSQL Storage: S3-compatible object storage Existing authentication and RBAC Existing REST API structure
[ENGINEERING_CONSTRAINTS_AND_REQUIREMENTS]: Do not break existing document uploads Invoice data must be tenant-isolated AI extraction must be replaceable Sensitive invoice data must not appear in logs API must return validation errors clearly
[AVAILABLE_CODING_AGENTS_AND_CAPABILITIES]: Architect Agent Backend Agent Frontend Agent Database Agent AI/ML Agent QA Agent Security Agent Integration Agent
[DELIVERY_CONSTRAINTS_AND_INTEGRATION_REQUIREMENTS]: Feature must be released behind a feature flag Database migration must be backward compatible Existing APIs must continue working No production rollout until integration and security checks pass
Example output
🎯 PHASE 1 — TASK SCOPE RECONSTRUCTION
Business Objective
Allow users to upload invoices and automatically convert unstructured invoice documents into structured, searchable invoice records.
Technical Objective
Create a pipeline:
PDF Upload → Document Storage → AI Extraction → Validation → Database → REST API → Dashboard
Expected Behavior
1. User uploads an invoice PDF.
2. System stores the document.
3. Processing job extracts invoice information.
4. Extracted information is validated.
5. Valid records are stored.
6. API exposes processing status and invoice data.
7. Dashboard displays the result.
8. Users can identify validation failures.
In Scope
Invoice database model
Invoice extraction service
Invoice validation
Processing workflow
REST endpoints
React dashboard
Automated tests
Security validation
Feature flag
Documentation
Out of Scope
Payment processing
Accounting-system integration
OCR engine development
Invoice editing workflow
Automated payment approval
Acceptance Criteria
Invoice PDFs can be submitted successfully.
Invoice fields are extracted into the defined schema.
Invalid or incomplete extraction is reported.
Invoice records are tenant-isolated.
API exposes processing state.
Dashboard displays processing results.
Existing document upload functionality remains unaffected.
CI passes.
Feature can be disabled using a feature flag.
🧩 PHASE 2 — WORKSTREAM DISCOVERY
The optimal decomposition is 8 tasks, rather than creating a separate agent for every tiny activity.
ID Workstream Owner
T1 Architecture + contracts Architect
T2 Database schema Database
T3 AI extraction engine AI/ML
T4 Backend processing pipeline Backend
T5 REST API Backend
T6 Dashboard Frontend
T7 Security + privacy validation Security
T8 End-to-end QA + integration QA/Integration
This avoids unnecessary coordination between too many agents.
🔗 PHASE 3 — TASK DEPENDENCY GRAPH
T1 Architecture
/ | \
/ | \
v v v
T2 T3 T7
Database AI Engine Security
\ /
\ /
v v
T4
Processing Pipeline
|
v
T5
API
|
v
T6
Dashboard
|
v
T8 QA/Integration
Dependency Classification
T1 → T2
🔴 Hard Dependency
Database agent needs the approved invoice schema and tenant-isolation strategy.
T1 → T3
🔴 Hard Dependency
AI agent needs the extraction contract.
T2 → T4
🔴 Hard Dependency
Processing pipeline needs the database model.
T3 → T4
🔴 Hard Dependency
Pipeline needs the extraction service interface.
T4 → T5
🔴 Strong Dependency
API needs processing status and persistence behavior.
T5 → T6
🔴 Hard Dependency
Frontend requires a stable API contract.
T7 → T8
🟠 Strong Dependency
Security findings must be resolved before final integration.
⚡ PHASE 4 — PARALLELIZATION ANALYSIS
⚡ PARALLEL
After T1 passes:
T2 Database
T3 AI extraction
T7 Security design review
These tasks have separate ownership boundaries.
🔒 SEQUENTIAL
T1 → T2 → T4 → T5 → T6 → T8
🔄 CONDITIONAL PARALLEL
T6 can begin API integration work using a mock API contract after T5's contract is approved, even while backend implementation continues.
However, final frontend integration must wait for the real API.
Important Conflict Prevention
The following files should have single ownership:
Database models → Database Agent
Extraction module → AI Agent
Processing orchestration → Backend Agent
API routes → Backend Agent
React invoice UI → Frontend Agent
Feature flag definition → Architect/Backend
Final integration configuration → Integration Agent
🤖 PHASE 5 — AGENT OWNERSHIP ASSIGNMENT
T1 — Architecture
Agent: Architect Agent
Owns:
System design
Data flow
API contract
Extraction schema
Feature-flag strategy
Must not modify:
Production implementation code
Deliverable: Approved architecture contract.
---
T2 — Database
Agent: Database Agent
Owns:
Invoice model
Migration
Indexes
Tenant constraints
Must not modify:
API
Frontend
AI extraction logic
Deliverable: Backward-compatible database migration.
---
T3 — AI Extraction
Agent: AI/ML Agent
Owns:
Extraction interface
Prompt/model adapter
Structured output parser
Extraction tests
Must not modify:
Database schema
API routes
Deliverable: Replaceable invoice extraction service.
---
T4 — Processing Pipeline
Agent: Backend Agent
Owns:
Processing orchestration
Validation
Persistence
Error handling
Deliverable: Working invoice-processing workflow.
---
T5 — REST API
Agent: Backend Agent
Owns:
Invoice endpoints
Processing status endpoint
API validation
Deliverable: Documented REST API.
---
T6 — Dashboard
Agent: Frontend Agent
Owns:
Invoice list
Processing status
Invoice details
Validation errors
Deliverable: Working React UI.
---
T7 — Security
Agent: Security Agent
Owns:
Tenant isolation review
Logging review
Authorization review
Sensitive-data handling
Deliverable: Security approval report.
---
T8 — Integration
Agents: QA + Integration Agent
Owns:
End-to-end testing
Regression testing
Contract testing
Feature-flag verification
Deliverable: Release-ready build.
🧠 PHASE 6 — CONTEXT REQUIREMENT DESIGN
T1 Context
Only needs:
Repository architecture
Existing upload flow
Authentication/RBAC
Existing API conventions
Database conventions
Feature-flag implementation
No need for the entire frontend.
T2 Context
Needs:
Existing database models
Tenant/user relationship
Migration conventions
PostgreSQL configuration
T1 schema contract
T3 Context
Needs:
Invoice extraction requirements
Expected JSON schema
AI provider abstraction
Existing document format
Error-handling conventions
T4 Context
Needs:
T2 database contract
T3 extraction interface
Existing document-storage service
Existing async/job infrastructure
T5 Context
Needs:
T4 processing contract
API conventions
Authentication/RBAC
Error-response format
T6 Context
Needs:
T5 OpenAPI/API contract
Existing React patterns
Dashboard components
Authentication state
T7 Context
Needs:
Architecture
Data flow
Authorization model
Logging configuration
AI data handling
T8 Context
Needs:
Entire feature contract
All completed artifacts
CI configuration
Test infrastructure
Feature-flag behavior
📜 PHASE 7 — SUBTASK SPECIFICATIONS
T1 — Architecture Contract
Objective: Define the complete technical contract.
Scope: Architecture artifacts only.
Inputs: Repository architecture + requirements.
Deliverables:
Invoice schema
Processing lifecycle
API contract
Extraction interface
Error model
Feature-flag strategy
Acceptance Criteria:
No unresolved architectural conflicts.
All downstream interfaces defined.
Tenant isolation explicitly defined.
Dependency: None.
T2 — Database
Objective: Implement invoice persistence.
Acceptance Criteria:
Migration succeeds.
Existing migrations remain compatible.
Tenant isolation is enforced.
Required indexes exist.
Rollback strategy documented.
Dependency: T1.
T3 — AI Extraction
Objective: Convert invoice documents into validated structured data.
Acceptance Criteria:
Defined interface implemented.
Structured output enforced.
Malformed model responses handled.
Provider can be replaced.
Unit tests cover successful and failed extraction.
Dependency: T1.
T4 — Processing Pipeline
Objective: Connect upload, extraction, validation, and persistence.
Acceptance Criteria:
Correct lifecycle states.
Failed extraction does not create corrupt records.
Retry behavior is deterministic.
Sensitive invoice content is excluded from logs.
Dependencies: T2 + T3.
T5 — API
Objective: Expose invoice processing and invoice data.
Acceptance Criteria:
Authorization enforced.
Tenant isolation verified.
Validation errors have stable structure.
Processing status is available.
Existing APIs remain unchanged.
Dependency: T4.
T6 — Dashboard
Objective: Provide UI for invoice processing/results.
Acceptance Criteria:
Upload state displayed.
Processing state displayed.
Success state displayed.
Validation errors displayed.
Unauthorized invoice access prevented.
Dependency: T5 contract.
T7 — Security
Objective: Validate security and privacy.
Acceptance Criteria:
No cross-tenant access.
No sensitive invoice data in logs.
RBAC correctly enforced.
AI provider data handling follows requirements.
Dependency: T1, with final validation against implementation.
T8 — Integration
Objective: Validate the entire feature.
Acceptance Criteria:
Backend tests pass.
Frontend tests pass.
Integration tests pass.
E2E flow passes.
Feature flag works.
Existing regression suite passes.
Dependencies: T2-T7.
🤝 PHASE 8 — HANDOFF CONTRACTS
T1 → T2
Artifact: Database Schema Contract
Contains:
Invoice
- id
- tenant_id
- document_id
- vendor_name
- invoice_number
- invoice_date
- subtotal
- tax
- total
- currency
- processing_status
- validation_errors
- created_at
- updated_at
Validation: Architect-approved.
---
T1 → T3
Artifact: Extraction Contract
Expected output:
{
"vendor_name": "...",
"invoice_number": "...",
"invoice_date": "...",
"subtotal": 0,
"tax": 0,
"total": 0,
"currency": "..."
}
The AI agent must not invent additional required fields.
---
T2 + T3 → T4
Artifact: Implementation Interfaces
T4 assumes:
Database model exists.
Extraction service follows the approved interface.
Extraction failures return defined error types.
---
T4 → T5
Artifact: Processing API Contract
Example states:
uploaded
processing
completed
validation_failed
failed
---
T5 → T6
Artifact: API/OpenAPI Contract
Frontend must consume only documented API fields.
---
T6 + Backend → T8
Artifact: Integrated feature.
Validation: Full automated test suite.
🧪 PHASE 9 — VERIFICATION CHECKPOINTS
Checkpoint V1 — Architecture
Trigger: T1 completed.
Check:
Interfaces complete
Dependencies identified
No ambiguous requirements
Failure: Return to T1.
---
Checkpoint V2 — Database
Trigger: T2 completed.
Check:
Migration
Schema
Tenant constraints
Integration tests
Failure: Database Agent fixes migration.
---
Checkpoint V3 — AI Extraction
Trigger: T3 completed.
Check:
Schema compliance
Malformed responses
Unit tests
Provider abstraction
---
Checkpoint V4 — Backend
Trigger: T4/T5 completed.
Check:
API contract
Authorization
Integration tests
Static analysis
---
Checkpoint V5 — Frontend
Trigger: T6 completed.
Check:
TypeScript
React tests
API integration
Error states
---
Checkpoint V6 — Security
Trigger: Security review completed.
Check:
Tenant isolation
RBAC
Sensitive logs
Data exposure
---
Checkpoint V7 — Release
Trigger: T8 completed.
Required:
Unit Tests PASS
Integration PASS
E2E PASS
Type Checks PASS
Lint PASS
Security PASS
Regression PASS
Feature Flag PASS
Only then is release permitted.
🚑 PHASE 10 — FAILURE & RECOVERY
Failure Detect Recovery
Wrong schema Contract test Return to T1
Migration failure CI Retry T2
AI output malformed Unit test Fix T3
API mismatch Contract test Reconcile T4/T5
Frontend mismatch Type/API test Update T6
Security failure Security tests Block release
Merge conflict Git integration Integration Agent resolves
Agent timeout Task timeout Fresh-context retry
Repeated failure 2 failed attempts Reassign
Architectural ambiguity Review Human escalation
🔄 PHASE 11 — RETRY & REASSIGNMENT
🔁 Same Agent Retry
Use when:
Tool failure
Temporary environment failure
Simple test failure
Missing generated artifact
🤖 Fresh Context Retry
Use when:
Agent misunderstood repository conventions
Context became polluted
Implementation became unnecessarily complex
🔄 Reassign
Use when:
Agent repeatedly violates boundaries
Specialized expertise is missing
Two implementation attempts fail
🧑💻 Human Escalation
Required when:
Requirements conflict
Architecture has multiple valid interpretations
Security requirements are unclear
Data migration strategy is uncertain
🛑 Stop
Stop execution when:
Fundamental requirement cannot be satisfied.
Migration would risk existing production data.
Security vulnerability cannot be resolved.
🧩 PHASE 12 — CROSS-TASK CONSISTENCY AUDIT
Before integration, verify:
Invoice field names are identical everywhere.
API types match database types.
Processing statuses are consistent.
Error codes are consistent.
Currency representation is consistent.
Date format is consistent.
Tenant ID handling is consistent.
AI extraction output matches backend expectations.
Frontend does not rely on undocumented fields.
🏗️ PHASE 13 — INTEGRATION STRATEGY
Safest sequence:
T1 Architecture
↓
T2 + T3 + T7
↓
T4
↓
T5
↓
T6
↓
T8
↓
Release
Integration should happen incrementally.
Do not merge all agents' work simultaneously.
Recommended sequence:
1. Merge database migration.
2. Run database integration tests.
3. Merge extraction service.
4. Run extraction tests.
5. Merge processing pipeline.
6. Run backend integration tests.
7. Merge API.
8. Run contract tests.
9. Merge dashboard.
10. Run E2E tests.
11. Apply security gate.
12. Enable feature flag in controlled environment.
🚦 PHASE 14 — DELIVERY GATES
GATE 1 — PLAN VALIDATION
Pass when:
Task boundaries defined.
Ownership defined.
Dependencies defined.
Unknowns resolved.
GATE 2 — CONTRACT VALIDATION
Pass when:
Database contract approved.
AI contract approved.
API contract approved.
Error model approved.
GATE 3 — IMPLEMENTATION VALIDATION
Pass when:
Each task passes its own tests.
Static analysis passes.
No ownership violations exist.
GATE 4 — INTEGRATION VALIDATION
Pass when:
Full feature works end-to-end.
No API mismatch exists.
No regression exists.
Security checks pass.
GATE 5 — RELEASE VALIDATION
Pass when:
Feature flag works.
Production configuration validated.
Rollback strategy tested/documented.
Acceptance criteria completely satisfied.
📊 PHASE 15 — OPTIMIZED EXECUTION ROADMAP
Task Agent Dependency Mode Complexity
T1 Architecture Architect None 🔒 Sequential Medium
T2 Database Database T1 ⚡ Parallel Medium
T3 AI Extraction AI/ML T1 ⚡ Parallel High
T7 Security Review Security T1 ⚡ Parallel Medium
T4 Processing Backend T2 + T3 🔒 Sequential High
T5 API Backend T4 🔒 Sequential Medium
T6 Dashboard Frontend T5 Contract 🔄 Conditional Medium
T8 Integration QA/Integration T2-T7 🔒 Sequential High
Critical Path
T1 → T2/T3 → T4 → T5 → T6 → T8
The AI extraction + processing pipeline is the highest technical-risk portion.
Main Bottlenecks
AI extraction reliability
Processing orchestration
API contract stability
End-to-end testing
Highest-Risk Areas
1. AI output inconsistency
2. Tenant isolation
3. Sensitive data leakage
4. Database migration
5. API/frontend contract mismatch
🧾 PHASE 16 — FINAL MULTI-AGENT CODING WORKFLOW BLUEPRINT
🎯 Task Decomposition Summary
The feature should not be split into dozens of agents.
The optimal structure is:
Architecture
↓
Database + AI + Security
↓
Processing
↓
API
↓
Frontend
↓
Integration
↓
Release
This gives meaningful parallelism while maintaining strict dependency boundaries.
🧩 Subtask Registry
T1 = Architecture & Contracts
T2 = Invoice Database
T3 = AI Extraction
T4 = Processing Pipeline
T5 = REST API
T6 = Dashboard
T7 = Security Review
T8 = Integration & E2E
🔗 Dependency Graph
┌── T2 ──┐
│ │
T1 ──────────────┼── T3 ──┼──> T4 ──> T5 ──> T6 ──> T8
│ │
└── T7 ──┘
T1 is the architectural control point.
T4 is the primary implementation bottleneck.
T8 is the final quality gate.
⚡ Parallelization Map
Wave 1
T1
Wave 2
T2 + T3 + T7
Wave 3
T4
Wave 4
T5
Wave 5
T6
Wave 6
T8
🤖 Agent Assignment Matrix
Agent Responsibility
Architect Architecture/contracts
Database Schema/migration
AI/ML Extraction
Backend Processing/API
Frontend Dashboard
Security Security/privacy
QA/Integration Full validation
🧠 Context Requirements
Each agent receives only:
Task specification
+
Relevant repository files
+
Required contracts
+
Previous task artifacts
+
Relevant tests
+
Explicit constraints
No agent automatically receives the entire repository.
🤝 Handoff Contracts
Every downstream task receives:
Artifact
Version
Schema/interface
Assumptions
Validation status
Known limitations
Failure conditions
This prevents agents from reconstructing decisions from code.
🧪 Verification Checkpoints
Architecture
↓ verify
Contracts
↓ verify
Individual implementations
↓ verify
Backend integration
↓ verify
Frontend integration
↓ verify
Security
↓ verify
E2E
↓ verify
Release
🚑 Failure Recovery Plan
FAILURE
↓
DETECT
↓
CONTAIN
↓
DIAGNOSE
↓
Is implementation problem?
├── YES → Retry/Reassign
│
└── NO
↓
Architecture problem?
├── YES → Escalate
└── NO → Resume
↓
VERIFY
↓
CONTINUE
🏗️ Integration Sequence
1. Architecture approved
2. Database migration integrated
3. AI extraction integrated
4. Processing pipeline integrated
5. API integrated
6. Frontend integrated
7. Security validation
8. Regression tests
9. E2E tests
10. Feature-flag validation
11. Release gate
12. Controlled rollout
🚨 Critical Risks
Risk 1: AI schema drift
Mitigation: strict structured-output contract + contract tests.
Risk 2: Tenant data leakage
Mitigation: authorization and tenant-isolation tests at database/API layers.
Risk 3: Migration incompatibility
Mitigation: backward-compatible migration + integration test against existing schema.
Risk 4: Agent assumption drift
Mitigation: explicit handoff contracts.
Risk 5: Merge conflicts
Mitigation: strict file ownership.
Risk 6: Cascading failures
Mitigation: verification checkpoints before downstream execution.
🛣️ Final Execution Roadmap
TASK INTAKE
↓
SCOPE RECONSTRUCTION
↓
ARCHITECTURE CONTRACT
↓
┌───────────────┬───────────────┬───────────────┐
│ DATABASE │ AI EXTRACTION│ SECURITY │
│ T2 │ T3 │ T7 │
└───────┬───────┴───────┬───────┴───────────────┘
└───────────┬───┘
↓
PROCESSING T4
↓
API T5
↓
DASHBOARD T6
↓
QA + INTEGRATION T8
↓
SECURITY GATE
↓
RELEASE GATE
↓
CONTROLLED ROLLOUT
🎯 Final Recommendation
The best strategy is contract-first, dependency-aware, bounded parallel execution.
The key design principle is:
Parallelize independent implementation, but serialize shared decisions and integration.
For this feature, the highest-value parallelization is Database + AI Extraction + Security after the architecture contract is frozen. Everything downstream should consume explicit, versioned contracts rather than assumptions.
This approach minimizes agent conflicts, prevents duplicated work, reduces context requirements, and gives you clear recovery points if an autonomous coding agent fails.
By purchasing this prompt, you agree to our terms of service
GPT-5.6
Large coding tasks become difficult for AI agents when work is poorly decomposed, dependencies are unclear, and multiple agents modify overlapping parts of a codebase.
🧩 Break large coding tasks into autonomous subtasks
🔗 Map dependencies between tasks
⚡ Separate parallel vs sequential work
🤖 Assign the right agent to each task
🧠 Define required context
🤝 Create precise agent handoff contracts
🧪 Design verification checkpoints
🚑 Plan failure recovery
🚀 Generate a safe final integration
...more
Added over 1 month ago
