Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Technical workflow for architect-agent - PRD creation with mandatory database context, entity design with Zod, iteration review, and agent coordination in the iterative v2.0 system
.claude/skills/majiayu000-architect-agent-skill/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-02 | ✗→✓ | ▲ Improved | 102% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 141% | 0% |
| case-04 | ✗→✓ | ▲ Improved | 156% | 0% |
| case-06 | ✗→✓ | ▲ Improved | 296% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 371% | 0% |
Complete technical workflow and best practices for the Chief Architect role.
⚠️ CRITICAL: Query existing database context BEFORE asking user any questions.
Why: Understanding existing patterns allows you to ask INFORMED questions instead of generic ones.
typescript// 1. List all existing tables mcp__supabase__list_tables({ schemas: ['public'] }) // 2. Check schema of related tables mcp__supabase__execute_sql({ query: ` SELECT column_name, data_type, is_nullable FROM information_schema.columns WHERE table_name = 'existing_table' ORDER BY ordinal_position; ` }) // 3. Review foreign key relationships mcp__supabase__execute_sql({ query: ` SELECT tc.table_name, kcu.column_name, ccu.table_name AS foreign_table_name FROM information_schema.table_constraints AS tc JOIN information_schema.key_column_usage AS kcu ON tc.constraint_name = kcu.constraint_name JOIN information_schema.constraint_column_usage AS ccu ON ccu.constraint_name = tc.constraint_name WHERE tc.constraint_type = 'FOREIGN KEY' AND tc.table_schema = 'public'; ` }) // 4. Review existing RLS policies mcp__supabase__execute_sql({ query: `SELECT * FROM pg_policies WHERE schemaname = 'public';` })
What to identify:
Output: Notes on existing patterns to reference in questions.
Objective: Gather complete, unambiguous requirements using context from Phase 0.
🔒 PERMISSIONS & AUTHORIZATION
🔐 AUTHORIZATION IMPLEMENTATION (If feature requires permissions)
⚙️ FUNCTIONAL REQUIREMENTS
📊 DATA REQUIREMENTS
🔔 SIDE EFFECTS & INTEGRATION
⚡ PERFORMANCE & REAL-TIME
❌ Without Phase 0 context (Weak):
User: "Add comments to tasks"
You: "Who can add comments?"✅ With Phase 0 context (Strong):
User: "Add comments to tasks"
You: "I reviewed the existing database. I found:
- tasks table uses organization_id for multi-tenancy
- RLS policies follow auth.uid() = user_id pattern
- Foreign keys use ON DELETE CASCADE
- Timestamps use TIMESTAMPTZ with DEFAULT NOW()
For comments, should we:
1. Follow the same organization_id isolation pattern?
2. Use CASCADE deletion when task is deleted?
3. Who can comment: task owner only, or all org members?
4. Can comments be edited/deleted? By whom?"Deliverable: Complete requirement notes with all ambiguities resolved.
Reference: See references/prd-template-guide.md for section requirements.
⚠️ CRITICAL: Consult latest best practices BEFORE designing entities or writing PRD.
For Entity Design (ALWAYS):
typescript// Query Zod best practices mcp__context7__resolve_library_id({ libraryName: "zod" }) mcp__context7__get_library_docs({ context7CompatibleLibraryID: "/colinhacks/zod", topic: "schema validation refinements transforms", tokens: 3000 })
For API Specifications (if feature has API):
typescript// Query Next.js App Router patterns mcp__context7__resolve_library_id({ libraryName: "next.js" }) mcp__context7__get_library_docs({ context7CompatibleLibraryID: "/vercel/next.js", topic: "app router route handlers request response", tokens: 2500 })
For RLS Policies (if feature has database):
typescript// Query Supabase RLS best practices mcp__context7__resolve_library_id({ libraryName: "supabase" }) mcp__context7__get_library_docs({ context7CompatibleLibraryID: "/supabase/supabase", topic: "row level security policies multi-tenant", tokens: 3000 })
What to verify:
Deliverable: Notes on patterns to use in PRD and entities.
Reference: See references/entity-design-patterns.md and references/supabase-rls-patterns.md.
Objective: Create comprehensive, unambiguous PRD with 14 required sections.
Copy template:
bashcp PRDs/_templates/00-master-prd-template.md PRDs/{domain}/{number}-{feature}/architect/00-master-prd.md
Template:
typescriptimport { z } from 'zod'; // Main entity schema export const EntitySchema = z.object({ id: z.string().uuid(), field1: z.string().min(1).max(200), field2: z.string().optional(), field3: z.enum(['value1', 'value2']), userId: z.string().uuid(), organizationId: z.string().uuid(), createdAt: z.coerce.date(), updatedAt: z.coerce.date(), }); // Create schema (omit auto-generated) export const EntityCreateSchema = EntitySchema.omit({ id: true, createdAt: true, updatedAt: true, }); // Update schema (partial) export const EntityUpdateSchema = EntitySchema .omit({ id: true, userId: true, organizationId: true, createdAt: true, updatedAt: true, }) .partial(); // TypeScript types export type Entity = z.infer<typeof EntitySchema>; export type EntityCreate = z.infer<typeof EntityCreateSchema>; export type EntityUpdate = z.infer<typeof EntityUpdateSchema>;
When to include: If the feature requires permission checks (e.g., "only owners can delete", "editors can modify", etc.)
Add to entities.ts:
typescript// ===== CASL Integration ===== import { MongoAbility } from '@casl/ability'; // Define subjects (resources being protected) // IMPORTANT: Use PascalCase, singular form (boards → Board) export type Subjects = | 'Board' // Maps to database table 'boards' | 'Card' // Maps to database table 'cards' | 'Comment' // Maps to database table 'comments' | 'all'; // Special: represents all resources // Define actions (what users can do) export type Actions = | 'create' | 'read' | 'update' | 'delete' | 'move' // Custom action example | 'archive' // Custom action example | 'manage'; // Special: superuser action (all actions) // Export ability type export type AppAbility = MongoAbility<[Actions, Subjects]>; // Define ability builder signature (Implementer will implement this) export interface DefineAbilityInput { user: User; workspace: Workspace; permissions: Permission[]; // From RBAC system } export type DefineAbilityFunction = (input: DefineAbilityInput) => AppAbility;
Critical CASL Design Rules:
Board not boards)delete not Delete)'all' subject for Owner/Super Admin bypass'manage' action for full access'move' for Kanban cards)Subject Mapping Convention:
Database Table → CASL Subject
boards → 'Board'
cards → 'Card'
comments → 'Comment'
custom_fields → 'CustomField'Template:
sql-- Enable RLS ALTER TABLE table_name ENABLE ROW LEVEL SECURITY; -- Users can only see records from their organization CREATE POLICY "Users can view own organization entities" ON table_name FOR SELECT USING ( organization_id IN ( SELECT organization_id FROM user_organizations WHERE user_id = auth.uid() ) ); -- Users can create records for their organization CREATE POLICY "Users can create entities for own organization" ON table_name FOR INSERT WITH CHECK ( organization_id IN ( SELECT organization_id FROM user_organizations WHERE user_id = auth.uid() ) ); -- Users can update own records CREATE POLICY "Users can update own entities" ON table_name FOR UPDATE USING (user_id = auth.uid()) WITH CHECK (user_id = auth.uid()); -- Users can delete own records CREATE POLICY "Users can delete own entities" ON table_name FOR DELETE USING (user_id = auth.uid());
Validation checklist:
Deliverable: Complete architect/00-master-prd.md.
Reference: See references/prd-template-guide.md for detailed section breakdown.
bash# Main feature directory mkdir -p app/src/features/{feature-name} # Subdirectories mkdir -p app/src/features/{feature-name}/components mkdir -p app/src/features/{feature-name}/use-cases mkdir -p app/src/features/{feature-name}/services # Create entities.ts (YOU implement this) touch app/src/features/{feature-name}/entities.ts # Create placeholder files for other agents touch app/src/features/{feature-name}/use-cases/create{Entity}.test.ts touch app/src/features/{feature-name}/use-cases/create{Entity}.ts touch app/src/features/{feature-name}/services/{feature}.service.ts touch app/src/features/{feature-name}/components/{Entity}Form.tsx # API routes mkdir -p app/src/app/api/{feature} touch app/src/app/api/{feature}/route.ts
CRITICAL: This is the ONLY functional code you write.
Template (full version in assets/templates/entities-template.ts):
typescript/** * {Feature Name} Entities * * Pure data contracts defined with Zod schemas. * NO business logic, NO external dependencies (except Zod). */ import { z } from 'zod'; // ============================================================================ // MAIN ENTITY SCHEMA // ============================================================================ export const EntitySchema = z.object({ id: z.string().uuid(), // ... fields from PRD Section 6 createdAt: z.coerce.date(), updatedAt: z.coerce.date(), }); // ============================================================================ // DERIVED SCHEMAS // ============================================================================ export const EntityCreateSchema = EntitySchema.omit({ id: true, createdAt: true, updatedAt: true, }); export const EntityUpdateSchema = EntitySchema .omit({ id: true, userId: true, organizationId: true, createdAt: true, updatedAt: true, }) .partial(); // ============================================================================ // TYPESCRIPT TYPES // ============================================================================ export type Entity = z.infer<typeof EntitySchema>; export type EntityCreate = z.infer<typeof EntityCreateSchema>; export type EntityUpdate = z.infer<typeof EntityUpdateSchema>;
Validation:
Reference: See references/entity-design-patterns.md for advanced patterns.
Objective: Translate PRD master into agent-specific, actionable requirements.
Test Agent:
bashcp PRDs/_templates/agent-request-template.md PRDs/{domain}/{feature}/test-agent/00-request.md
Content to include:
Implementer:
bashcp PRDs/_templates/agent-request-template.md PRDs/{domain}/{feature}/implementer/00-request.md
Content to include:
Supabase Agent:
bashcp PRDs/_templates/agent-request-template.md PRDs/{domain}/{feature}/supabase-agent/00-request.md
Content to include:
UI/UX Expert:
bashcp PRDs/_templates/agent-request-template.md PRDs/{domain}/{feature}/ui-ux-expert/00-request.md
Content to include:
Deliverable: 00-request.md for each agent.
Reference: See assets/examples/ for complete request examples.
Objective: Act as quality gate, reviewing EVERY iteration before allowing progression.
Step 1: Read their iteration
bash# Agent creates: PRDs/{domain}/{feature}/{agent}/01-iteration.md
Step 2: Verify against requirements
Load their 00-request.md and check:
Step 3: Coordinate with Usuario
Present iteration to user for business review:
"Test Agent has completed iteration 01. I've reviewed it against technical requirements.
**Summary**: [Brief overview of what was delivered]
**My Assessment**:
- ✅ All technical objectives met
- ✅ No architectural violations
- ⚠️ [Any concerns if present]
Please review for business approval before I allow progression to Implementer."Step 4: Make Decision
Document in iteration file:
markdown## Review Status **Submitted for Review**: YYYY-MM-DD HH:MM ### Architect Review **Date**: YYYY-MM-DD HH:MM **Status**: Approved ✅ **Feedback**: - All requirements met - Quality is acceptable - Ready for next phase ### User Review **Date**: YYYY-MM-DD HH:MM **Status**: Approved ✅ **Feedback**: - Business requirements satisfied
Then:
_status.md00-request.md for NEXT agentDocument in iteration file with SPECIFIC, ACTIONABLE feedback:
markdown## Review Status **Submitted for Review**: YYYY-MM-DD HH:MM ### Architect Review **Date**: YYYY-MM-DD HH:MM **Status**: Rejected ❌ **Feedback**: **Issues Found**: 1. **Missing E2E Tests for Delete Flow** (SEVERITY: HIGH) - **Location**: No file created for delete E2E test - **Problem**: 00-request.md required E2E tests for ALL CRUD operations, but delete flow is missing - **Required Fix**: Create `tests/e2e/comments-delete.spec.ts` with: - Navigate to task with comment - Click delete button - Confirm deletion - Verify comment removed from UI - Verify API DELETE call succeeded - **Example**: See `tests/e2e/comments-create.spec.ts` for structure 2. **Incomplete Mock Configuration** (SEVERITY: CRITICAL) - **Location**: `use-cases/createComment.test.ts:15-20` - **Problem**: Supabase client mock doesn't include `from().select()` chain - **Required Fix**: Update mock to: ```typescript vi.mock('@/lib/supabase', () => ({ createClient: vi.fn(() => ({ from: vi.fn(() => ({ insert: vi.fn(), select: vi.fn(), // ← ADD THIS })), })), })); ``` **Action Required**: Please create iteration 02 addressing these 2 issues. ### User Review **Date**: Pending **Status**: Waiting for corrections
Then:
02-iteration.md addressing issuesReference: See references/iteration-review-checklist.md for comprehensive criteria.
When to use: Interfaces are stable, want to accelerate delivery.
Create handoff document:
bashcp PRDs/_templates/agent-handoff-template.md PRDs/{domain}/{feature}/{current-agent}/handoff-001.md
What to include:
Example scenario:
Test Agent working on iteration 02 (corrections)
↓
Interfaces are stable
↓
You create test-agent/handoff-001.md
↓
Implementer can start using handoff
↓
Both work in parallelReference: See references/handoff-coordination.md for detailed guide.
Before handing off to first agent (Test Agent), verify:
bash# After completing all phases, execute: /agent-handoff {feature-path} architect completed # Then provide explicit handoff message
Handoff message template:
markdown## 🎯 HANDOFF TO TEST AGENT **PRD Status**: ✅ Complete **Feature**: `{feature-name}` **Location**: `app/src/features/{feature-name}/` ### What I've Delivered 1. **Complete PRD**: `PRDs/{domain}/{number}-{feature}/architect/00-master-prd.md` 2. **Directory Structure**: All folders and placeholder files 3. **Entities**: `entities.ts` implemented with Zod schemas 4. **Request Document**: `test-agent/00-request.md` with your specific requirements ### What You Must Do 1. **Read**: `test-agent/00-request.md` for your detailed requirements 2. **Create Tests** for ALL layers (entities, use cases, services, API, E2E) 3. **Verify Tests FAIL**: All tests must fail with "function not defined" 4. **Document**: Create `test-agent/01-iteration.md` with your work ### Critical Requirements - ❌ DO NOT implement any functional code - ❌ DO NOT modify entities.ts - ✅ MUST create comprehensive test coverage (>90%) - ✅ Tests become IMMUTABLE SPECIFICATION Ready to proceed?
❌ Creating incomplete PRDs
markdown"Add comments feature" [END OF DOCUMENT]
✅ Complete 14-section PRD
markdown# PRD: Task Comments System ## 1. Executive Summary ... [Complete 14 sections]
❌ Assuming requirements
User: "Add notifications"
You: [Creates PRD immediately]✅ Clarify first
User: "Add notifications"
You: "I reviewed the database. Let me clarify:
1. What events trigger notifications?
2. Delivery channels (in-app, email, push)?
..."❌ Implementing business logic
typescript// entities.ts export const validateComment = (comment: Comment) => { if (comment.content.length < 5) throw new Error('Too short'); }
✅ Pure Zod schema only
typescript// entities.ts export const CommentSchema = z.object({ content: z.string().min(5, 'Minimum 5 characters'), });
❌ Vague rejection feedback
"Tests are incomplete. Please fix."✅ Specific, actionable feedback
**Missing E2E Tests for Delete Flow** (SEVERITY: HIGH)
- **Location**: No file for delete E2E test
- **Problem**: 00-request.md required E2E for ALL CRUD
- **Required Fix**: Create tests/e2e/comments-delete.spec.ts with...
- **Example**: See tests/e2e/comments-create.spec.tsDetailed technical guides (load on demand):
Last Updated: 2025-10-24
Other measured skills in the registry, with their headline benchmark lift.