| name | wave-coherence-validation |
| description | Validates that wave tasks build upon existing implementations in logical dependency order |
| tier | 2 |
| category | Quality & Architecture |
| depends_on | ["architectural-conformance-validation","development-best-practices"] |
| related_agents | ["wave-planner","backend-specialist","frontend-specialist","implementation-validator"] |
Wave Coherence Validation Skill
Purpose
This skill ensures that tasks within a wave are implemented in the correct dependency order by:
- Analyzing existing implementations in current and parent branches
- Detecting dependencies between components (database → API → UI)
- Verifying API endpoints match expected contracts before integration
- Preventing out-of-order implementation that causes rework
- Building dependency graphs to guide implementation sequence
Key Insight: Code changes should build coherently upon existing implementations, not assume future implementations or ignore existing patterns.
When to Invoke This Skill
Required Invocation (MUST Use)
Invoke this skill before starting implementation work in these scenarios:
Recommended Invocation (SHOULD Use)
Invoke this skill when:
Working With Other Skills
Before this skill:
architectural-conformance-validation - Ensure architecture decisions are followed
git-repository-setup-validation - Verify branches are properly setup
After this skill:
development-best-practices - Implement with proper standards
implementation-velocity-tracking - Track completion after validation
Skill Workflow
Step 1: Scope Analysis
Objective: Determine what code is available in current and parent branches
Actions:
-
Identify current branch and parent
git branch --show-current
git show-branch | grep '*' | grep -v "$(git rev-parse --abbrev-ref HEAD)" | head -1 | sed 's/.*\[\(.*\)\].*/\1/'
-
Get commit history for context
git log --oneline parent-branch..HEAD
git log --oneline HEAD..parent-branch
-
List files changed in current branch
git diff --name-status parent-branch...HEAD
Validation Checklist:
Step 2: Dependency Detection
Objective: Identify dependencies between components in the wave
Actions:
-
Scan for database schema changes
find . -path "*/migrations/*" -name "*.sql" -o -name "*.js" -o -name "*.ts"
find . -name "*schema*" -o -name "*model*" | grep -E "\.(ts|js|py|sql)$"
-
Scan for API endpoints
grep -r "router\.\(get\|post\|put\|delete\|patch\)" --include="*.ts" --include="*.js"
grep -r "@\(Get\|Post\|Put\|Delete\|Patch\)" --include="*.ts" --include="*.java"
grep -r "@app\.\(get\|post\|put\|delete\|patch\)" --include="*.py"
-
Scan for service layer components
find . -name "*service*" -o -name "*repository*" | grep -E "\.(ts|js|py|java)$"
grep -r "class.*Service\|class.*Repository" --include="*.ts" --include="*.js" --include="*.py"
-
Scan for UI components
find . -name "*.tsx" -o -name "*.jsx" -o -name "*.vue"
grep -r "fetch\|axios\|http\.get\|http\.post" --include= --include= --include=
Build Dependency Map:
Database Schema
↓
Types/Interfaces (DTOs)
↓
Repository/Data Access Layer
↓
Service Layer (Business Logic)
↓
API Controllers/Endpoints
↓
Frontend API Clients
↓
UI Components
Validation Checklist:
Step 3: API Endpoint Verification (Priority Order)
Objective: Verify existing API endpoints match expected contracts
Priority 1: Test Endpoint (If Running Locally)
curl -s http://localhost:3000/health || echo "Server not running"
curl -X GET http://localhost:3000/api/users/123
curl -X POST http://localhost:3000/api/users \
-H "Content-Type: application/json" \
-d '{"name":"Test","email":"test@example.com"}'
Capture Response Format:
{
"actual_response": {
"id": "123",
"name": "Test User",
"email": "test@example.com"
},
"status_code": 200,
"headers": {
"content-type": "application/json"
}
}
Priority 2: Read Code Implementation
If endpoint cannot be tested, read the code:
router.get('/users/:id', async (req, res) => {
const user = await userService.getById(req.params.id);
res.json(user);
});
Priority 3: Check Existing Tests
If code is unclear, look for tests:
find . -name "*.test.ts" -o -name "*.spec.ts" | xargs grep -l "users"
cat src/routes/users.test.ts
it('should return user by id', async () => {
const response = await request(app)
.get('/api/users/123')
.expect(200);
expect(response.body).toEqual({
id: '123',
name: expect.any(String),
email: expect.any(String)
});
});
Validation Checklist:
Step 4: Coherence Analysis
Objective: Identify out-of-order implementations and missing dependencies
Check 1: Missing Lower-Layer Dependencies
grep -r "fetch('/api/users')" src/components/
grep -r "router.get('/users')" src/routes/
Warning Example:
⚠️ BLOCKER: UI component calls /api/users but endpoint not implemented
Location: src/components/UserList.tsx:15
Missing: GET /api/users endpoint
Action Required: Implement API endpoint before UI component
Check 2: Schema Mismatch Between Layers
res.json({ user_id: user.id, user_name: user.name });
const { id, name } = await response.json();
Warning Example:
⚠️ SCHEMA MISMATCH: Frontend expects different field names than API provides
API Response: { user_id, user_name }
Frontend Expects: { id, name }
Location: src/components/UserList.tsx:20
Action Required: Either update frontend to use user_id/user_name OR update API to use id/name
Check 3: Missing Type Definitions
export function getUser(id: string): Promise<User> { ... }
Warning Example:
⚠️ MISSING DEPENDENCY: Service references undefined type 'User'
Location: src/services/userService.ts:5
Missing: User interface/type definition
Action Required: Define User interface before implementing service
Check 4: Database Changes Not Reflected in Code
ALTER TABLE users ADD COLUMN role VARCHAR(50);
res.json({ id: user.id, name: user.name });
Warning Example:
⚠️ UNUSED SCHEMA CHANGE: Database column 'role' added but not used in API
Migration: migrations/001_add_user_role.sql
API: src/routes/users.ts (doesn't include 'role' in response)
Action Required: Either use 'role' in API response OR remove migration if not needed
Validation Checklist:
Step 5: Dependency Graph Generation
Objective: Create visual dependency graph showing implementation order
Example Output:
Wave Coherence Validation Report
================================
Current Branch: feature-1.10-infrastructure
Parent Branch: epic-1-progressive-coherence
Dependency Graph (Bottom-Up Order):
====================================
1. [✅ DONE] Database Schema
└─ migrations/001_create_users_table.sql (committed: abc123)
2. [✅ DONE] Type Definitions
└─ src/types/user.ts (committed: def456)
└─ Exports: User interface
3. [✅ DONE] Repository Layer
└─ src/repositories/userRepository.ts (committed: ghi789)
└─ Depends on: User interface
└─ Exports: UserRepository class
4. [✅ DONE] Service Layer
└─ src/services/userService.ts (committed: jkl012)
└─ Depends on: UserRepository
└─ Exports: UserService class
5. [⚠️ IN PROGRESS] API Endpoints
└─ src/routes/users.ts (uncommitted changes)
└─ Depends on: UserService
└─ Implements: GET /api/users, POST /api/users
└─ ⚠️ WARNING: POST /api/users not tested yet
6. [🔴 BLOCKED] Frontend API Client
└─ src/api/userApi.ts (not implemented)
└─ Depends on: API endpoints (GET /api/users, POST /api/users)
└─ 🔴 BLOCKER: Cannot implement until API endpoints tested and merged
7. [🔴 BLOCKED] UI Components
└─ src/components/UserList.tsx (not implemented)
└─ Depends on: Frontend API client
└─ 🔴 BLOCKER: Cannot implement until API client exists
Blockers Summary:
=================
🔴 2 blockers found
1. Frontend API Client (src/api/userApi.ts)
- BLOCKED BY: Untested API endpoint POST /api/users
- ACTION: Test API endpoint, verify request/response format
- SEQUENCE: Complete #5 (API Endpoints) before starting #6
2. UI Components (src/components/UserList.tsx)
- BLOCKED BY: Missing frontend API client
- ACTION: Implement API client first
- SEQUENCE: Complete #6 (Frontend API Client) before starting #7
Warnings:
=========
⚠️ 1 warning found
1. API Endpoint Not Tested
- LOCATION: src/routes/users.ts:25 (POST /api/users)
- ISSUE: Endpoint implemented but no test verification
- ACTION: Start dev server and test endpoint OR write unit test
- PRIORITY: High (blocks frontend work)
Recommended Implementation Sequence:
====================================
✅ Steps 1-4 complete
➡️ Next: Complete step 5 (test API endpoint)
Then: Proceed to step 6 (frontend API client)
Finally: Proceed to step 7 (UI components)
Coherence Status: ⚠️ WARNINGS (safe to proceed with caution)
Step 6: Integration Contract Validation
Objective: When integrating frontend ↔ backend, verify contracts match
Example Workflow:
-
API Contract (Already Implemented)
router.post('/users', async (req, res) => {
const user = await userService.create(req.body);
res.status(201).json(user);
});
-
Frontend Implementation (Current Wave)
export async function createUser(userData: CreateUserDTO) {
const response = await fetch('/api/users', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(userData)
});
return response.json();
}
-
Validation Checks
Validation Checklist:
Output Format
Successful Validation
status: PASS
message: "Wave coherence validated. All dependencies in correct order."
branch:
current: feature-1.10-infrastructure
parent: epic-1-progressive-coherence
dependencies:
total: 7
completed: 7
in_progress: 0
blocked: 0
blockers: []
warnings: []
recommendation: "Proceed with implementation. All dependencies available."
Validation with Warnings
status: WARNING
message: "Wave coherence validated with warnings. Review before proceeding."
branch:
current: feature-1.10-infrastructure
parent: epic-1-progressive-coherence
dependencies:
total: 7
completed: 4
in_progress: 1
blocked: 2
blockers:
- component: "Frontend API Client"
file: "src/api/userApi.ts"
blocked_by: "Untested API endpoint POST /api/users"
action: "Test API endpoint before implementing frontend client"
sequence: "Complete API testing (#5) before starting #6"
warnings:
- type: "UNTESTED_API"
location: "src/routes/users.ts:25"
message: "POST /api/users implemented but not tested"
priority: "high"
action: "Test endpoint to verify request/response format"
recommendation: "Complete API testing before proceeding to frontend work."
dependency_graph: |
1. [✅] Database Schema
2. [✅] Type Definitions
3. [✅] Repository Layer
4. [✅] Service Layer
5. [⚠️] API Endpoints (untested)
6. [🔴] Frontend API Client (blocked)
7. [🔴] UI Components (blocked)
Validation Failure
status: FAIL
message: "Wave coherence validation failed. Critical blockers found."
branch:
current: feature-1.10-infrastructure
parent: epic-1-progressive-coherence
dependencies:
total: 7
completed: 2
in_progress: 1
blocked: 4
blockers:
- component: "Service Layer"
file: "src/services/userService.ts"
blocked_by: "Missing type definition 'User'"
action: "Define User interface before implementing service"
sequence: "Must complete #2 (Type Definitions) before #4 (Service Layer)"
- component: "API Endpoints"
file: "src/routes/users.ts"
blocked_by: "Missing service layer implementation"
action: "Implement UserService before API routes"
sequence: "Must complete #4 (Service Layer) before #5 (API Endpoints)"
warnings:
- type: "OUT_OF_ORDER"
location: "src/routes/users.ts"
message: "Attempting to implement API before service layer exists"
Integration with Other Skills
Works With: architectural-conformance-validation
Sequence:
- Run
architectural-conformance-validation first (verify architecture decisions)
- Run
wave-coherence-validation second (verify implementation order)
Example:
architectural-conformance-validation:
status: PASS
message: "Changes conform to layered architecture pattern"
wave-coherence-validation:
status: PASS
message: "Dependencies in correct order"
Works With: development-best-practices
Sequence:
- Run
wave-coherence-validation (verify dependencies available)
- Run
development-best-practices during implementation (verify code quality)
Example:
wave-coherence-validation:
status: PASS
recommendation: "Proceed with API endpoint implementation"
development-best-practices:
- Check file existence before import ✅
- Verify API signatures ✅
- Externalize configuration ✅
Used By: wave-planner
Workflow:
wave-planner invokes wave-coherence-validation
↓
Skill analyzes dependencies
↓
Returns dependency graph + blockers
↓
wave-planner creates tasks in correct sequence
↓
wave-planner assigns tasks respecting dependency order
Used By: Implementation Agents
Workflow:
backend-specialist invoked for API implementation
↓
Invokes wave-coherence-validation
↓
Skill checks: Are service layer dependencies available?
↓
Status: PASS → Proceed with implementation
Status: FAIL → Report blockers to user, wait for dependencies
Reference Files
See references/ directory for:
- dependency-detection-patterns.md: Common code patterns for detecting dependencies
- api-contract-verification.md: Detailed API testing and verification procedures
- coherence-anti-patterns.md: Common out-of-order implementation mistakes
Scripts
See scripts/ directory for:
- analyze-dependencies.sh: Automated dependency scanning
- test-api-contract.sh: API endpoint testing script
- generate-dependency-graph.sh: Dependency graph generation
Common Issues
Issue 1: "Cannot find dependency in current or parent branch"
Problem: Code references component that doesn't exist in git history
Solution:
- Check if component is in uncommitted changes
- Check if component is in different feature branch (needs merge)
- Create component if truly missing
Issue 2: "API endpoint returns different format than expected"
Problem: Frontend expects one format, API returns another
Solution:
- Test API endpoint to see actual response
- Update frontend to match API response
- OR update API to match expected format (if API is wrong)
- Ensure both use same type definitions
Issue 3: "Circular dependency detected"
Problem: Component A depends on B, but B also depends on A
Solution:
- Extract shared code to separate module
- Use dependency injection to break cycle
- Refactor to remove circular dependency
Success Criteria
This skill is successful when:
✅ All dependencies identified correctly
✅ Dependency order validated (no out-of-order implementations)
✅ API contracts verified (if endpoints exist)
✅ Blockers clearly identified with actionable guidance
✅ Dependency graph generated and easy to understand
✅ Implementation sequence recommended
✅ Integration between layers validated
This skill has failed if:
❌ Dependencies missed (implementation fails due to missing code)
❌ False positives (reports blockers that don't exist)
❌ Unclear guidance (user doesn't know what to do next)
❌ API contract mismatch not detected (integration breaks)
Example Usage
Example 1: Starting Wave Implementation
Input:
current_branch: feature-1.10-infrastructure
parent_branch: epic-1-progressive-coherence
wave_tasks:
- Implement user database schema
- Create user API endpoints
- Build user management UI
Output:
status: PASS
recommendation: "Implement in sequence: schema → API → UI"
dependency_graph:
1. [⚠️ TODO] Database Schema (migrations/create_users.sql)
2. [🔴 BLOCKED] API Endpoints (blocked by
3. [🔴 BLOCKED] UI Components (blocked by
next_step:
Example 2: Frontend Integration
Input:
current_branch: feature-1.10-infrastructure
parent_branch: epic-1-progressive-coherence
integration_points:
- Frontend: src/components/UserList.tsx
- API: GET /api/users
Output:
status: WARNING
warnings:
- type: UNTESTED_API
message: "API endpoint exists but not tested"
recommendation: "Test API endpoint before integration"
api_test_result:
endpoint: GET /api/users
test_command: "curl http://localhost:3000/api/users"
expected_response: "[{ id, name, email }]"
next_step: "Run API test, verify response format, then implement frontend"
Last Updated: 2025-01-30
Version: 1.0