parallel-agent-contracts
npx machina-cli add skill parcadei/Continuous-Claude-v3/parallel-agent-contracts --openclawFiles (1)
SKILL.md
2.0 KB
Parallel Agent Type Contracts
When launching parallel agents for code implementation, prevent type duplication.
Required in Every Agent Prompt
1. Verification Command (MANDATORY)
## Before Marking Complete
Run verification:
\`\`\`bash
npx tsc --noEmit 2>&1 | head -20
\`\`\`
If ANY type errors exist, fix them before completing.
2. Grep-Before-Create
## Before Creating Any Type/Interface
First check if it exists:
\`\`\`bash
grep -r "interface YourTypeName\|type YourTypeName" src/
\`\`\`
If found, import it. NEVER duplicate existing types.
3. Canonical Type Map
Include relevant entries from this map in agent prompts:
| Type | Owner File | Import From |
|---|---|---|
NormalizedTool | src/sdk/agent.ts | './agent' |
ToolCall | src/sdk/agent.ts | './agent' |
ToolResult | src/sdk/agent.ts | './agent' |
ToolDefinition | src/sdk/agent.ts | './agent' |
Message | src/sdk/types.ts | './types' |
ContentBlock | src/sdk/types.ts | './types' |
TokenUsage | src/sdk/types.ts | './types' |
ProviderAdapter | src/sdk/providers/index.ts | './providers' |
RiggClient | src/sdk/client.ts | './client' |
Prompt Template
When spawning implementation agents:
# Task: [Description]
## Type Ownership (DO NOT recreate)
- [List relevant types from canonical map]
## Before Creating New Types
Run: `grep -r "interface TypeName" src/` - if exists, import it.
## Before Marking Complete
Run: `npx tsc --noEmit 2>&1 | head -20`
Fix all type errors before completing.
## Your Implementation
[Actual task description]
Why This Works
- Type checker is the contract - tsc catches conflicts automatically
- Grep is fast - 1 second to check if type exists
- Explicit ownership - No ambiguity about where types live
- Fail fast - Agent can't claim "done" with broken types
Source
git clone https://github.com/parcadei/Continuous-Claude-v3/blob/main/.claude/skills/parallel-agent-contracts/SKILL.mdView on GitHub Overview
Parallel Agent Type Contracts prevent type duplication when launching parallel agents for code implementation. It enforces mandatory checks (tsc verification and grep-before-create) and relies on a canonical type map to keep types centralized.
How This Skill Works
It makes type-checking mandatory before completion by running npx tsc --noEmit to catch any type errors. It also uses a grep-before-create step to detect existing types and imports them instead of recreating, guided by the Canonical Type Map for ownership.
When to Use It
- Launching multiple agents in parallel to implement code without duplicating shared types.
- Adding new task-specific types in a shared repo while preserving central ownership.
- Ensuring existing types from the canonical map (e.g., NormalizedTool, Message, RiggClient) are reused instead of redefined.
- Onboarding new team members to parallel-agent workflows with clear type ownership.
- Maintaining strict type ownership across modules when coordinating Tool, Message, and ProviderAdapter definitions.
Quick Start
- Step 1: In your task prompt, include only the relevant types from the canonical map and avoid recreating them.
- Step 2: Before creating new types, run: grep -r "interface TypeName" src/ - if exists, import it.
- Step 3: Before marking complete, run: npx tsc --noEmit 2>&1 | head -20 and fix all type errors.
Best Practices
- Always run the verification step before marking completion.
- Consult the Canonical Type Map and import paths to avoid duplication.
- Use grep-before-create before any type/interface creation.
- Keep prompts referencing only existing/imported types from the canonical map.
- Document import sources and ownership in agent prompts for future maintainers.
Example Use Cases
- An agent uses NormalizedTool, ToolCall, and ToolResult from src/sdk/agent.ts and imports './agent' without redefining types.
- Before adding a ToolDefinition, the agent checks for existing TypeScript types in src/sdk/agent.ts.
- When an existing Message and ContentBlock are needed, the agent imports from src/sdk/types.ts rather than recreating.
- Integrating ProviderAdapter is done by referencing src/sdk/providers/index.ts and importing from './providers'.
- RiggClient integration is validated by checking src/sdk/client.ts and importing from './client' instead of creating new types.
Frequently Asked Questions
Add this skill to your agents