This skill teaches agents how to assess task complexity, enforce quality gates, and prevent wasted work on incomplete or poorly-defined tasks. Inspired by production-grade development practices, qu...
Version: 1.0.0 Type: Quality Assurance & Risk Management Auto-activate: Task planning, complexity assessment, requirement gathering, before task execution
This skill teaches agents how to assess task complexity, enforce quality gates, and prevent wasted work on incomplete or poorly-defined tasks. Inspired by production-grade development practices, quality gates ensure agents have sufficient context before proceeding and automatically escalate when stuck or blocked.
Key Principle: Stop and clarify before proceeding with incomplete information. Better to ask questions than to waste cycles on the wrong solution.
Assess every task on a 1-5 complexity scale:
Level 1: Trivial
Level 2: Simple
Level 3: Moderate
Level 4: Complex
Level 5: Very Complex
BLOCKING Conditions (MUST resolve before proceeding):
Incomplete Requirements (>3 critical questions)
Missing Dependencies (blocked by another task)
Stuck Detection (3 attempts at same task)
Evidence Failure (tests/builds failing)
Complexity Overflow (Level 4-5 tasks without breakdown)
WARNING Conditions (Can proceed with caution):
Moderate Complexity (Level 3)
1-2 Unanswered Questions
1-2 Failed Attempts
## Quality Gate Check
**Task:** [Task description]
**Complexity:** [1-5 scale]
**Dependencies:** [List dependencies]
### Critical Questions (Must answer before proceeding)
1. [Question 1] - ✅ Answered / ❌ Unknown
2. [Question 2] - ✅ Answered / ❌ Unknown
3. [Question 3] - ✅ Answered / ❌ Unknown
**Unanswered Critical Questions:** [Count]
### Dependency Check
- [ ] All required APIs exist
- [ ] Database schema ready
- [ ] Required services running
- [ ] External APIs accessible
- [ ] Authentication configured
**Blocked Dependencies:** [List]
### Attempt History
- Attempt 1: [What was tried, outcome]
- Attempt 2: [What was tried, outcome]
- Attempt 3: [What was tried, outcome]
**Failed Attempts:** [Count]
### Gate Status
- ✅ **PASS** - Can proceed
- ⚠️ **WARNING** - Proceed with caution
- ❌ **BLOCKED** - Must resolve before proceeding
### Blocking Reasons (if blocked)
- [ ] >3 critical questions unanswered
- [ ] Missing dependencies
- [ ] 3+ failed attempts (stuck)
- [ ] Evidence shows failures
- [ ] Complexity too high without plan
### Actions Required
[List actions needed to unblock]
When: Before starting any task (especially Level 3-5)
Steps:
Assess Complexity
Read task description
Count file changes needed
Estimate lines of code
Identify dependencies
Count unknowns
→ Assign complexity score (1-5)
Identify Critical Questions
What must I know to complete this?
- Data structures?
- Expected behaviors?
- Edge cases?
- Error handling?
- API contracts?
→ List all critical questions
→ Count unanswered questions
Check Dependencies
What does this task depend on?
- Other tasks?
- External services?
- Database changes?
- Configuration?
→ Verify dependencies ready
→ List blockers
Gate Decision
if (unansweredQuestions > 3) → BLOCK
if (missingDependencies > 0) → BLOCK
if (complexity >= 4 && !hasPlan) → BLOCK
if (complexity == 3) → WARN
else → PASS
Document in Context
context.tasks_pending.push({
id: 'task-' + Date.now(),
task: "Task description",
complexity_score: 3,
gate_status: 'pass',
critical_questions: [...],
dependencies: [...],
timestamp: new Date().toISOString()
});
When: After multiple failed attempts at same task
Steps:
Track Attempts
// In context, track attempts
if (!context.attempt_tracking) {
context.attempt_tracking = {};
}
if (!context.attempt_tracking[taskId]) {
context.attempt_tracking[taskId] = {
attempts: [],
first_attempt: new Date().toISOString()
};
}
context.attempt_tracking[taskId].attempts.push({
timestamp: new Date().toISOString(),
approach: "Describe what was tried",
outcome: "Failed because X",
error_message: "Error details"
});
Check Threshold
const attemptCount = context.attempt_tracking[taskId].attempts.length;
if (attemptCount >= 3) {
// ESCALATE - stuck
return {
status: 'blocked',
reason: 'stuck_after_3_attempts',
escalate_to: 'user',
attempts_history: context.attempt_tracking[taskId].attempts
};
}
Escalation Message
## 🚨 Escalation: Task Stuck
**Task:** [Task description]
**Attempts:** 3
**Status:** BLOCKED - Need human guidance
### What Was Tried
1. **Attempt 1:** [Approach] → Failed: [Reason]
2. **Attempt 2:** [Approach] → Failed: [Reason]
3. **Attempt 3:** [Approach] → Failed: [Reason]
### Current Blocker
[Describe the persistent problem]
### Need Guidance On
- [Specific question 1]
- [Specific question 2]
**Recommendation:** Human review needed to unblock
When: Assigned a Level 4 or 5 complexity task
Steps:
Break Down into Subtasks
## Task Breakdown: [Main Task]
**Overall Complexity:** Level 4
### Subtasks
1. **Subtask 1:** [Description]
- Complexity: Level 2
- Dependencies: None
- Estimated: 2 hours
2. **Subtask 2:** [Description]
- Complexity: Level 3
- Dependencies: Subtask 1
- Estimated: 4 hours
3. **Subtask 3:** [Description]
- Complexity: Level 2
- Dependencies: Subtask 2
- Estimated: 2 hours
**Total Estimated:** 8 hours
**Complexity Check:** All subtasks ≤ Level 3 ✅
Validate Breakdown
Check:
- [ ] All subtasks are Level 1-3
- [ ] Dependencies clearly mapped
- [ ] Each subtask has clear acceptance criteria
- [ ] Sum of estimates reasonable
- [ ] No overlapping work
Create Execution Plan
## Execution Plan
**Phase 1:** Subtask 1
- Start: After requirements confirmed
- Gate check: Pass
- Evidence: Tests pass, build succeeds
**Phase 2:** Subtask 2
- Start: After Subtask 1 complete
- Gate check: Verify Subtask 1 evidence
- Evidence: Integration tests pass
**Phase 3:** Subtask 3
- Start: After Subtask 2 complete
- Gate check: End-to-end verification
- Evidence: Full feature tests pass
When: Starting a new feature or significant task
Steps:
Functional Requirements Check
## Functional Requirements
- [ ] **Happy path defined:** What should happen when everything works?
- [ ] **Error cases defined:** What should happen when things fail?
- [ ] **Edge cases identified:** What are the boundary conditions?
- [ ] **Input validation:** What inputs are valid/invalid?
- [ ] **Output format:** What should the output look like?
- [ ] **Success criteria:** How do we know it works?
Technical Requirements Check
## Technical Requirements
- [ ] **API contracts:** Endpoints, methods, schemas defined?
- [ ] **Data structures:** Models, types, interfaces specified?
- [ ] **Database changes:** Schema migrations needed?
- [ ] **Authentication:** Who can access this?
- [ ] **Performance:** Any latency/throughput requirements?
- [ ] **Security:** Any special security considerations?
Count Critical Unknowns
const criticalUnknowns = [
!functionalRequirements.happyPath,
!functionalRequirements.errorCases,
!technicalRequirements.apiContracts,
!technicalRequirements.dataStructures
].filter(unknown => unknown).length;
if (criticalUnknowns > 3) {
return {
gate_status: 'blocked',
reason: 'incomplete_requirements',
critical_unknowns: criticalUnknowns,
action: 'clarify_requirements'
};
}
# Quality Gate: [Task Name]
**Date:** [YYYY-MM-DD]
**Agent:** [Agent name]
## Complexity Assessment
**Estimated Lines of Code:** [X]
**Estimated Duration:** [X hours]
**File Changes:** [X files]
**Dependencies:** [X dependencies]
**Unknowns:** [X unknowns]
**Complexity Score:** Level [1-5]
## Critical Questions
1. [Question 1] - ✅ Answered / ❌ Unknown
2. [Question 2] - ✅ Answered / ❌ Unknown
3. [Question 3] - ✅ Answered / ❌ Unknown
**Unanswered:** [Count]
## Dependency Check
**Required:**
- [ ] [Dependency 1] - Ready / Blocked
- [ ] [Dependency 2] - Ready / Blocked
**Blockers:** [List]
## Gate Decision
**Status:** ✅ PASS / ⚠️ WARNING / ❌ BLOCKED
**Reasoning:** [Why this decision]
**Actions Required:** [If blocked or warning]
**Can Proceed:** Yes / No
# Escalation: Task Stuck
**Task:** [Task description]
**Agent:** [Agent name]
**Date:** [YYYY-MM-DD]
## Attempt History
**Attempt 1** ([Timestamp])
- **Approach:** [What was tried]
- **Outcome:** Failed
- **Error:** [Error message or issue]
**Attempt 2** ([Timestamp])
- **Approach:** [What was tried]
- **Outcome:** Failed
- **Error:** [Error message or issue]
**Attempt 3** ([Timestamp])
- **Approach:** [What was tried]
- **Outcome:** Failed
- **Error:** [Error message or issue]
## Current Blocker
[Detailed description of persistent problem]
## Need Guidance
1. [Specific question requiring human input]
2. [Specific question requiring human input]
## Recommendation
**Escalate to:** User / Studio Coach / Specific Agent
**Suggested Actions:** [What might unblock this]
# Task Breakdown: [Main Task]
**Original Complexity:** Level [4-5]
**Goal:** Break down to Level 1-3 subtasks
## Subtasks
### Subtask 1: [Name]
- **Complexity:** Level [X]
- **Estimated Duration:** [X hours]
- **Dependencies:** [None / List]
- **Acceptance Criteria:**
- [ ] [Criterion 1]
- [ ] [Criterion 2]
### Subtask 2: [Name]
- **Complexity:** Level [X]
- **Estimated Duration:** [X hours]
- **Dependencies:** [List]
- **Acceptance Criteria:**
- [ ] [Criterion 1]
- [ ] [Criterion 2]
### Subtask 3: [Name]
- **Complexity:** Level [X]
- **Estimated Duration:** [X hours]
- **Dependencies:** [List]
- **Acceptance Criteria:**
- [ ] [Criterion 1]
- [ ] [Criterion 2]
## Validation
- [ ] All subtasks ≤ Level 3
- [ ] Dependencies clearly mapped
- [ ] No circular dependencies
- [ ] Acceptance criteria clear
- [ ] Total estimate reasonable
**Can Proceed:** Yes / No
Quality gates integrate with the context system for tracking:
// Add gate check to context
context.quality_gates = context.quality_gates || [];
context.quality_gates.push({
task_id: taskId,
timestamp: new Date().toISOString(),
complexity_score: 3,
gate_status: 'pass', // pass, warning, blocked
critical_questions_count: 1,
unanswered_questions: 1,
dependencies_blocked: 0,
attempt_count: 0,
can_proceed: true
});
Quality gates check for evidence before allowing completion:
// Before marking task complete
const evidence = context.quality_evidence;
const hasPassingEvidence = (
evidence?.tests?.exit_code === 0 ||
evidence?.build?.exit_code === 0
);
if (!hasPassingEvidence) {
return {
gate_status: 'blocked',
reason: 'no_passing_evidence',
action: 'collect_evidence_first'
};
}
// ❌ BAD: Start immediately
function startTask(task) {
implementTask(task);
}
// ✅ GOOD: Gate check first
function startTask(task) {
const gateCheck = runQualityGate(task);
if (gateCheck.status === 'blocked') {
escalate(gateCheck.reason);
return;
}
if (gateCheck.status === 'warning') {
documentAssumptions(gateCheck.warnings);
}
implementTask(task);
}
When proceeding with warnings, document assumptions:
## Assumptions Made
1. **Assumption:** API will return JSON format
**Risk:** Low - standard REST practice
**Mitigation:** Add try-catch for parsing
2. **Assumption:** User authentication already implemented
**Risk:** Medium - might not exist
**Mitigation:** Check early, escalate if missing
// Track every attempt
function attemptTask(taskId, approach) {
trackAttempt(taskId, approach);
const attemptCount = getAttemptCount(taskId);
if (attemptCount >= 3) {
escalateToUser(taskId);
return 'blocked';
}
return executeApproach(approach);
}
// ❌ BAD: Tackle Level 5 task directly
implementComplexFeature();
// ✅ GOOD: Break down first
function handleComplexTask(task) {
if (task.complexity >= 4) {
const subtasks = breakDownIntoSubtasks(task);
subtasks.forEach(subtask => {
runQualityGate(subtask);
implementSubtask(subtask);
});
} else {
implementTask(task);
}
}
**Problem:** Assume task is simple, skip gate check, get stuck later
**Solution:** Always run gate check, even for Level 1-2 tasks (quick check)
**Problem:** Proceed with warnings without documenting assumptions
**Solution:** Document every assumption when proceeding with warnings
**Problem:** Keep trying same approach repeatedly, waste cycles
**Solution:** Track every attempt, escalate after 3
**Problem:** Gate says BLOCKED but proceed anyway "to make progress"
**Solution:** NEVER bypass BLOCKED gates - resolve blockers first
3 critical questions unanswered → BLOCK
1. Assess complexity (1-5)
2. Count critical questions unanswered
3. Check dependencies blocked
4. Check attempt count
if (questions > 3 || dependencies blocked || attempts >= 3) → BLOCK
else if (complexity >= 4 && no plan) → BLOCK
else if (complexity == 3 || questions 1-2) → WARNING
else → PASS
v1.0.0 - Initial release
Remember: Quality gates prevent wasted work. Better to ask questions upfront than to build the wrong solution. When in doubt, BLOCK and escalate.