Skip to content
Shell

feat: Add Pattern 6 (Agent-Native Design) to ID8Pipeline

Eddie Belavalfbf6dcaea14a
diff --git a/CLAUDE.md b/CLAUDE.md
index 238dcb3..5a8ca42 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -98,6 +98,34 @@ Recommendation: [choice] because [reasoning]
**Signal:** "Looking at this from multiple angles..."
+## Pattern 6: Agent-Native Design
+
+**When building features that agents will use, ensure:**
+
+1. **Parity** - Agent can achieve anything the UI can do
+ - For each UI action, verify an agent tool exists
+ - Document in PARITY_MAP.md
+
+2. **Granularity** - Tools are atomic primitives
+ - Avoid bundling judgment into tools
+ - Features = outcomes described in prompts, not hardcoded logic
+
+3. **CRUD Completeness** - Every entity has full agent access
+ - Create, Read, Update, Delete for ALL entities
+ - Audit during Stage 5
+
+4. **Completion Signals** - Agents explicitly signal "done"
+ - Tools return `{ success, output, shouldContinue }`
+ - Never detect completion via heuristics
+
+5. **Context Injection** - Agents know what exists
+ - Maintain context.md with user state, resources, recent activity
+ - Update on each significant action
+
+**Trigger:** Any feature that involves agent tools, AI capabilities, or automated workflows.
+
+**Signal to user:** "Agent-native check: [PASS/FAIL] - [what's missing]"
+
---
## Applying These Patterns
@@ -105,11 +133,13 @@ Recommendation: [choice] because [reasoning]
**Always apply:**
- Metacognitive (confidence signaling)
- PEV (verification before commits)
+- Agent-Native (when building agent-facing features)
**Apply when appropriate:**
- Reflection (significant code changes)
- Tree of Thoughts (complex decisions)
- Ensemble (important architectural choices)
+- Agent-Native (audit parity, CRUD, completion signals)
**Don't over-apply:** Simple tasks don't need heavy process. Use judgment.
@@ -222,10 +252,22 @@ Every project flows through these stages in order. Hard stops at each gate.
**Gate:** V1 boundaries are explicit. Max 5 core features. "Not yet" list defined.
**Checkpoint:** "What are we NOT building?"
+**Agent-Native Addition:**
+- [ ] Identify which features will have agent capabilities
+- [ ] For agent features, define: What outcomes should agents achieve?
+- [ ] Document in PIPELINE_STATUS.md: "Agent Scope"
+
### Stage 3: Architecture Sketch
**Gate:** Stack chosen, components mapped, data flow clear.
**Checkpoint:** "Draw me the boxes and arrows."
+**Agent-Native Addition:**
+- [ ] Create PARITY_MAP.md with all planned UI actions
+- [ ] Design tool architecture (atomic primitives, not bundled)
+- [ ] Define entity list for CRUD audit
+- [ ] Choose file vs. database for agent-generated content
+- [ ] Plan context.md structure for this project
+
### Stage 4: Foundation Pour
**Gate:** Scaffolding, database, auth, deployment pipeline all running.
**Checkpoint:** "Can we deploy an empty shell?"
@@ -234,10 +276,38 @@ Every project flows through these stages in order. Hard stops at each gate.
**Gate:** Build vertical slices. One complete feature at a time. No half-builds.
**Checkpoint:** "Does this feature work completely, right now?"
+**Agent-Native Addition (per feature):**
+- [ ] CRUD Complete: Can agent Create, Read, Update, Delete this entity?
+- [ ] Completion Signals: Does tool return `shouldContinue`?
+- [ ] Parity: Update PARITY_MAP.md with implemented tools
+- [ ] Approval Flow: What stakes/reversibility? (see matrix below)
+
+**Approval Flow Matrix:**
+| Stakes | Reversibility | Pattern | Example |
+|--------|--------------|---------|---------|
+| Low | Easy | Auto-apply | Organize files |
+| Low | Hard | Quick confirm | Publish to feed |
+| High | Easy | Suggest + apply | Code changes |
+| High | Hard | Explicit approval | Send email, delete |
+
### Stage 6: Integration Pass
**Gate:** All blocks connected. Data flows between components.
**Checkpoint:** "Do all the pieces talk to each other?"
+**Agent-Native Addition:**
+- [ ] Agent-to-UI events standardized (AgentEvent types)
+- [ ] context.md updates on all significant actions
+- [ ] Tools can compose (agent can combine primitives for new outcomes)
+- [ ] No silent agent actions - all visible in UI
+
+**AgentEvent Types (standardize across products):**
+- `thinking(message)` → Show thinking indicator
+- `toolCall(tool, params)` → Show tool being used
+- `toolResult(result)` → Show result (optional)
+- `textResponse(text)` → Stream to chat
+- `statusChange(status)` → Update status bar
+- `complete(summary)` → Signal done
+
### Stage 7: Test Coverage
**Gate:** Full test pyramid implemented and passing. No skipped tests. Coverage thresholds met.
**Checkpoint:** "Are all tests green and is coverage sufficient?"
@@ -259,6 +329,14 @@ Every project flows through these stages in order. Hard stops at each gate.
**Tools:** Use `testing-suite` plugin commands, Playwright for E2E, Jest/Vitest for unit/integration.
+**Agent-Native Addition:**
+- [ ] Parity tests: For each UI action, test agent can achieve same outcome
+- [ ] CRUD tests: Every entity has Create/Read/Update/Delete agent tests
+- [ ] Completion signal tests: Verify tools return proper signals
+- [ ] Context tests: Verify context.md updates correctly
+
+**Required test file:** `__tests__/agent-parity.test.ts` (if agent features exist)
+
### Stage 8: Polish & Harden
**Gate:** Error handling, loading states, empty states, edge cases covered.
**Checkpoint:** "What breaks if I do something stupid?"
@@ -275,6 +353,19 @@ Every project flows through these stages in order. Hard stops at each gate.
**Gate:** Feedback loop active.
**Checkpoint:** "What did we learn?"
+**Agent-Native Addition (Latent Demand Discovery):**
+- [ ] Log agent requests that succeed (signal of what's working)
+- [ ] Log agent requests that fail (reveals capability gaps)
+- [ ] Weekly review: What are users asking agents to do?
+- [ ] Pattern emerging? → Add domain tool or prompt
+- [ ] Pattern failing? → Add missing primitive
+
+**Discovery Template:**
+| User Request | Agent Response | Outcome | Action |
+|--------------|---------------|---------|--------|
+| "Summarize my week" | Used read_notes + analysis | Success | Consider dedicated tool |
+| "Send reminder email" | No email tool | Failed | Add email primitive |
+
---
## Enforcement
@@ -312,6 +403,9 @@ When user says:
- "pipeline status" → Report current stage and next checkpoint
- "checkpoint cleared" → Advance to next stage, update PIPELINE_STATUS.md
- "skip to [stage]" → Require reason, log override, proceed
+- "parity check" → Run PARITY_MAP.md audit, report gaps
+- "crud audit" → Check all entities have full CRUD agent access
+- "agent-native status" → Report Pattern 6 compliance for current project
---
diff --git a/templates/PARITY_MAP.md.template b/templates/PARITY_MAP.md.template
new file mode 100644
index 0000000..3a48cba
--- /dev/null
+++ b/templates/PARITY_MAP.md.template
@@ -0,0 +1,98 @@
+# Parity Map
+
+> This file documents every UI action and how an agent achieves the same outcome.
+> Create during Stage 3 (Architecture Sketch). Update during Stage 5 (Feature Blocks).
+> The goal: Agent can do anything the user can do through the UI.
+
+## Project: [Project Name]
+
+---
+
+## Entity: [Entity Name 1]
+
+| User Action | Agent Tool | Status | Notes |
+|-------------|-----------|--------|-------|
+| Create | `create_[entity](name, type, properties)` | ⬜ Planned | |
+| Read (single) | `get_[entity](id)` | ⬜ Planned | |
+| Read (list) | `list_[entities](filters)` | ⬜ Planned | |
+| Update | `update_[entity](id, changes)` | ⬜ Planned | |
+| Delete | `delete_[entity](id)` | ⬜ Planned | |
+| Search | `search_[entities](query)` | ⬜ Planned | |
+
+### CRUD Status: 0/4 Complete
+
+---
+
+## Entity: [Entity Name 2]
+
+| User Action | Agent Tool | Status | Notes |
+|-------------|-----------|--------|-------|
+| Create | `create_[entity](...)` | ⬜ Planned | |
+| Read | `get_[entity](...)` | ⬜ Planned | |
+| Update | `update_[entity](...)` | ⬜ Planned | |
+| Delete | `delete_[entity](...)` | ⬜ Planned | |
+
+### CRUD Status: 0/4 Complete
+
+---
+
+## Other UI Actions
+
+| User Action | Agent Tool | Status | Notes |
+|-------------|-----------|--------|-------|
+| [Action 1] | `tool_name(params)` | ⬜ Planned | |
+| [Action 2] | `tool_name(params)` | ⬜ Planned | |
+
+---
+
+## Audit Summary
+
+| Metric | Value |
+|--------|-------|
+| **Total UI Actions** | 0 |
+| **Agent Parity** | 0/0 (0%) |
+| **CRUD Complete Entities** | 0/0 |
+| **Missing Tools** | [list] |
+
+---
+
+## Status Legend
+
+- ⬜ **Planned** - Designed, not yet implemented
+- 🔨 **In Progress** - Currently being built
+- ✅ **Complete** - Implemented and tested
+- ❌ **Missing** - Not planned, creates parity gap
+- 🔄 **Partial** - Some functionality, not complete
+
+---
+
+## Approval Flow Classification
+
+For each action, classify by stakes and reversibility:
+
+| Action | Stakes | Reversibility | Pattern |
+|--------|--------|--------------|---------|
+| Create entity | Low | Easy | Auto-apply |
+| Delete entity | High | Hard | Explicit approval |
+| Update entity | Low | Easy | Auto-apply |
+| Publish content | Low | Hard | Quick confirm |
+
+---
+
+## Completion Signals Audit
+
+For each tool, verify it returns proper completion signals:
+
+| Tool | Returns `shouldContinue`? | Notes |
+|------|--------------------------|-------|
+| `create_entity` | ⬜ TODO | |
+| `delete_entity` | ⬜ TODO | |
+
+---
+
+## How to Use This File
+
+1. **Stage 3:** Create this file with all planned UI actions
+2. **Stage 5:** Update status as tools are implemented
+3. **Stage 7:** Verify all ✅ tools have parity tests
+4. **"parity check" command:** Claude audits this file and reports gaps
diff --git a/templates/context.md.template b/templates/context.md.template
new file mode 100644
index 0000000..74fea74
--- /dev/null
+++ b/templates/context.md.template
@@ -0,0 +1,52 @@
+# Context
+
+> This file provides agents with session state, user preferences, and knowledge of what exists.
+> Update this file on significant actions. Agents read this at session start.
+
+## Who I Am
+
+[Agent name and purpose for this project]
+- Example: "Lexicon assistant for the Three Musketeers universe"
+- Example: "MILO life planning coach for daily productivity"
+
+## What I Know About This User
+
+- [Preference 1: e.g., "Prefers concise responses"]
+- [Preference 2: e.g., "Focused on Q1 goals"]
+- [Current focus: e.g., "Working on chapter summaries"]
+
+## What Exists
+
+- [Entity count] [entity type] in [location]
+ - Example: "47 entities in Neo4j"
+ - Example: "12 notes in /notes"
+- [Entity count] [entity type] in [location]
+- Settings at [path]
+
+## Recent Activity
+
+- [Action] ([relative time])
+ - Example: "Created 'Cardinal Richelieu' entity (2 hours ago)"
+- [Action] ([relative time])
+ - Example: "Searched for 'duels' (yesterday)"
+
+## My Guidelines
+
+- [Guideline 1: e.g., "Don't spoil books the user is currently reading"]
+- [Guideline 2: e.g., "Use their interests to personalize insights"]
+- [Guideline 3: e.g., "Prefer graph visualization when showing relationships"]
+
+## Current State
+
+- Pending tasks: [list or "None"]
+- Active session: [description or "None"]
+- Last sync: [timestamp]
+
+---
+
+## How to Update This File
+
+1. **On entity creation/deletion:** Update "What Exists" counts
+2. **On user action:** Add to "Recent Activity" (keep last 5-10)
+3. **On preference learned:** Add to "What I Know About This User"
+4. **On session end:** Update "Current State" with pending tasks