Workflow execution protocol and phase transition rules
When a user requests ANY module work, follow this exact protocol.
User says: "Add operation X to module Y"
↓
You MUST:
1. Identify: What module? What operation?
2. Choose workflow: add-operation.md
3. START EXECUTING - Don't just explore!
🚨 BEFORE doing ANY work, ALWAYS check for credentials:
Check multiple common locations:
# 1. Check module .env file
ls .env 2>/dev/null && echo "Found .env" || echo "No .env"
# 2. Check module .connectionProfile.json
ls .connectionProfile.json 2>/dev/null && echo "Found .connectionProfile.json" || echo "No .connectionProfile.json"
# 3. Check repository root .env (go up to find it)
ls ../../.env 2>/dev/null && echo "Found root .env" || echo "No root .env"
# 4. Check for credentials in any found files
if [ -f .env ]; then
cat .env | grep -iE "(MODULE|SERVICE|VENDOR)_(API_?KEY|TOKEN|PASSWORD|SECRET|EMAIL)"
fi
if [ -f .connectionProfile.json ]; then
cat .connectionProfile.json | jq '.' 2>/dev/null
fi
Credential location flexibility:
.env, .connectionProfile.json, ../.env, ../../.env*_API_KEY, *_TOKEN, *_PASSWORD, *_SECRET, *_EMAIL🔍 Checking for credentials...
I found these files but I'm not sure which contains credentials:
- [list of found files]
Where should I look for credentials for [Module Name]?
Or provide the credential location/values.
Note on credential naming:
GITHUB_TOKEN vs GITHUB_API_KEY vs GITHUB_ACCESS_TOKEN)IF credentials are NOT available:
⚠️ Credentials not found in .env file.
Required credentials for [Module Name]:
- CREDENTIAL_VAR_1: [description]
- CREDENTIAL_VAR_2: [description]
What would you like to do?
1. Provide credentials now (I'll wait)
2. Continue without credentials (integration tests will be skipped)
IF credentials ARE available:
Rationale: Many tasks require credentials for testing. Checking early prevents wasted work and ensures user controls the execution approach.
🚨 CRITICAL: Re-read rules at the start of EVERY new step/task!
BEFORE starting work, load these files:
api-spec-core-rules.md - Core API rules (Rules 1-10)api-spec-operations.md - Operation patterns (Rules 11-13)api-spec-schemas.md - Schema design (Rules 14-24)api-spec-standards.md - Standards & guidelinesgate-1-api-spec.md - Gate 1 validationimplementation.md - Implementation patternserror-handling.md - Error typestype-mapping.md - Type conversionsgate-3-implementation.md - Gate 3 validationtesting.md - Test requirementsgate-4-test-creation.md - Gate 4 validationgate-5-test-execution.md - Gate 5 validationprerequisites.md - Before any workFor ANY operation addition:
# 1. Update API specification
edit api.yml
→ VALIDATE: No errors, correct naming, descriptions added
# 2. IMMEDIATELY generate types (NEVER SKIP!)
npm run clean && npm run generate
→ VALIDATE: Types generated successfully
# 3. Check what was generated
ls generated/api/
cat generated/model/NewType.ts
# 4. ONLY THEN implement using generated types
edit src/SomeProducer.ts # Use the generated types!
→ VALIDATE: No 'any' types, using generated types
# 5. WRITE TESTS (MANDATORY!)
edit test/SomeProducerTest.ts # Unit tests
edit test/integration/SomeIntegrationTest.ts # Integration tests
→ VALIDATE: Tests complete for operation
# 6. RUN TESTS (MANDATORY!)
npm test
→ VALIDATE: All tests pass
# 7. Build and validate
npm run build
→ VALIDATE: Build successful
DO NOT STOP UNTIL ALL 7 STEPS COMPLETE!
See gate-1-api-spec.md through gate-6-build.md for complete gate definitions.
All operations must pass through 6 validation gates sequentially:
Task is ONLY complete when ALL gates pass.
Fix: Remove them! Only 200/201 allowed
any type in method signature"Fix: Run npm run clean && npm run generate first, use generated types
Fix: ALWAYS: api.yml → generate → implement
Fix: Check rules DURING execution, not after
1. Read request
2. CHECK FOR CREDENTIALS - Ask user if missing
3. Load required rules (see Step 2)
4. Open workflow task
5. Execute step by step with validation gates
6. RE-READ RULES before each new step
7. Generate before implement
8. Write tests WITHOUT being asked
9. Run tests and build
User: "Add getAccessToken operation"
// ❌ WRONG - Jumping straight to implementation
async getAccessToken(): Promise<any> { // NO!
// ✅ CORRECT - Follow protocol
// 1. Update api.yml with operation
// 2. Run npm run clean && npm run generate
// 3. Import AccessToken from generated
// 4. Implement with proper type
async getAccessToken(): Promise<AccessToken> { // YES!
// 5. Write tests (unit + integration)
// 6. Run tests - verify all pass
// 7. Build - verify success
| User Says | Use This Task |
|---|---|
| "Analyze X API" or "Create API diagram" | workflow/tasks/analyze-api.md |
| "Create X module" | workflow/tasks/create-module.md |
| "Add X operation" | workflow/tasks/add-operation.md |
| "Add X operations" (multiple) | workflow/tasks/update-module.md |
| "Fix X issue" | workflow/tasks/fix-module.md |
Before ANY implementation:
The workflow and rules only work if you EXECUTE them, not just READ them!
When user says "add operation":
api-specification.md, implementation.md, testing.md, ENFORCEMENT.mdSTOP EXPLORING - START EXECUTING!
For complete enforcement details, see completion-checklist.md.