xiaohongshu
xiaohongshu
architect-agent-skill
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
Full skill instructions
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.
// 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):
// 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):
// 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):
// 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:
cp PRDs/_templates/00-master-prd-template.md PRDs/{domain}/{number}-{feature}/architect/00-master-prd.md
Template:
import { 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:
// ===== 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:
-- 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.
# 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):
/**
* {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:
cp PRDs/_templates/agent-request-template.md PRDs/{domain}/{feature}/test-agent/00-request.md
Content to include:
Implementer:
cp PRDs/_templates/agent-request-template.md PRDs/{domain}/{feature}/implementer/00-request.md
Content to include:
Supabase Agent:
cp PRDs/_templates/agent-request-template.md PRDs/{domain}/{feature}/supabase-agent/00-request.md
Content to include:
UI/UX Expert:
cp 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
# 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:
## 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:
## 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:
cp 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 parallel
Reference: See references/handoff-coordination.md for detailed guide.
Before handing off to first agent (Test Agent), verify:
# After completing all phases, execute:
/agent-handoff {feature-path} architect completed
# Then provide explicit handoff message
Handoff message template:
## 🎯 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
"Add comments feature" [END OF DOCUMENT]
✅ Complete 14-section PRD
# 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
// entities.ts
export const validateComment = (comment: Comment) => {
if (comment.content.length < 5) throw new Error('Too short');
}
✅ Pure Zod schema only
// 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.ts
Detailed technical guides (load on demand):
Last Updated: 2025-10-24
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience