Multi-Agent Workflow

December 26, 2025 · View on GitHub

Use multiple AI agents to review specs and code from different perspectives. Each agent has unique strengths - use one as your primary development tool, and others for review.

Why Multi-Agent?

AgentStrengthBest For
Your Primary ToolImplementation, context retentionPrimary development, code generation
ChatGPTPattern recognition, alternativesSpec review, code audit, security
GeminiEdge cases, gap analysisArchitecture review, completeness

Supported primary tools: Claude Code, Gemini CLI, Codex CLI, Cursor, or any MCP-compatible assistant.

Using multiple agents catches issues that a single agent might miss due to training biases or blind spots.

Available Prompts

ChatGPT Prompts

PromptWhen to Use
spec-review.mdAfter drafting requirements or design
code-audit.mdAfter implementation, before merge
security.mdFor security-sensitive features
pre-launch.mdBefore production release

Gemini Prompts

PromptWhen to Use
gap-analysis.mdAfter requirements, find what's missing
edge-cases.mdBefore implementation, identify corner cases
architecture.mdAfter design, validate architecture

The manual workflow is recommended for most teams. It provides full control and doesn't require API keys.

Step 1: Generate Audit Request

ldf audit --type spec-review --spec user-auth

This generates an audit request in audit-request.md format.

Step 2: Send to External Agent

  1. Open ChatGPT or Gemini
  2. Paste the relevant prompt file (e.g., prompts/chatgpt/spec-review.md)
  3. Paste the audit request content
  4. Submit and wait for response

Step 3: Process Response

  1. Copy the response
  2. Create an audit-response.md file using the template
  3. Triage issues (valid vs invalid)
  4. Create action items

Step 4: Import Feedback

ldf audit --import audit-response.md --spec user-auth

This saves the audit findings to .ldf/audit-history/ for tracking.

Step 5: Address Issues

  1. Update specs based on valid issues
  2. Re-audit if critical issues were found
  3. Close the audit when complete

Workflow Diagram

┌─────────────────────────────────────────────────────────────┐
│  1. Primary AI drafts spec                                  │
│  2. Run: ldf audit --type spec-review --spec [name]         │
│  3. LDF generates audit-request.md                          │
│  4. User copies to ChatGPT/Gemini with prompt               │
│  5. External agent returns structured feedback              │
│  6. User saves feedback as audit-response.md                │
│  7. Run: ldf audit --import audit-response.md               │
│  8. Primary AI incorporates feedback                        │
│  9. Repeat until approved                                   │
└─────────────────────────────────────────────────────────────┘

When to Audit

PhaseAudit TypeAgentTrigger
Requirementsspec-reviewChatGPTDraft complete
Requirementsgap-analysisGeminiBefore approval
DesignarchitectureGeminiDraft complete
DesignsecurityChatGPTIf security-sensitive
Pre-Implementationedge-casesGeminiAfter design approval
Implementationcode-auditChatGPTBefore merge
Pre-Launchpre-launchChatGPTBefore release
Pre-LaunchfullBothComprehensive review

Audit Templates

TemplatePurpose
audit-request.mdStructure for sending specs/code to agents
audit-response.mdStructure for processing agent feedback

Best Practices

DO

  • Run spec-review after every major requirements change
  • Run security-check for auth, payment, PII features
  • Run architecture review for new services
  • Document all audit findings, even if deferred
  • Re-audit after significant spec changes

DON'T

  • Skip audits to save time (they catch expensive bugs)
  • Accept all findings without review (agents make mistakes)
  • Use automation without understanding the prompts
  • Ignore "low priority" security findings

Audit Tracking

Track audits in your spec metadata:

## Audit History

| Date | Type | Agent | Result | Issues |
|------|------|-------|--------|--------|
| 2024-01-15 | spec-review | ChatGPT | NEEDS_REVISION | 3 high, 2 medium |
| 2024-01-16 | spec-review | ChatGPT | APPROVE | 0 critical |
| 2024-01-18 | architecture | Gemini | APPROVE | 1 medium |

Automated Workflow (Optional)

For teams wanting API automation, see automation/README.md.

Prerequisites:

  • OpenAI API key (for ChatGPT)
  • Google AI API key (for Gemini)
  • Configuration in .ldf/config.yaml

Usage:

# Automated spec review with ChatGPT
ldf audit --type spec-review --spec user-auth --api --agent chatgpt

# Gap analysis with Gemini
ldf audit --type gap-analysis --spec user-auth --api --agent gemini

# Full audit (all types) with auto-import
ldf audit --type full --api --agent chatgpt --auto-import

# This will:
# 1. Generate audit request
# 2. Send to the specified API
# 3. Parse response
# 4. Save to .ldf/audit-history/
# 5. Auto-import if --auto-import flag is set

FAQ

Which agent should I use first?

Start with ChatGPT for spec-review, then Gemini for gap-analysis. They catch different issues.

How long does a review take?

Manual: 10-15 minutes per spec. Automated: 2-3 minutes per spec.

What if agents disagree?

Review both perspectives. If they disagree on something important, that's valuable signal - investigate further.

Can I use other agents?

Yes! Create custom prompts in prompts/[agent-name]/. The workflow is agent-agnostic.

Should I audit every spec?

For production features: yes. For prototypes or experiments: use judgment.