Meta-Questions for Recursive Agents

James Phoenix
James Phoenix

There are questions you can ask agents at any point: “Is the work done? Are there bugs? What tests am I missing?” These spawn recursive improvement loops.

Udemy Bestseller

Learn Prompt Engineering

My O'Reilly book adapted for hands-on learning. Build production-ready prompts with practical exercises.

4.5/5 rating
306,000+ learners
View Course

The Core Idea

Agents can ask meta-questions about their own work. These questions trigger recursive self-improvement:

Agent completes task
        ↓
Ask: "Is this actually done?"
        ↓
Agent evaluates own work
        ↓
Finds gaps → spawns more work
        ↓
Repeat until truly done

This is how humans naturally work. Agents can do it too.


The Universal Meta-Questions

These questions apply to almost any task:

Question What It Catches
“Is the work actually done?” Incomplete implementations
“Are there bugs in this code?” Logic errors, edge cases
“What tests am I missing?” Coverage gaps
“What could go wrong?” Failure modes
“Does this match the spec?” Spec drift
“What should we do next?” Missing follow-up work
“What did I assume?” Hidden assumptions
“How could this fail in production?” Operational issues

Implementing Meta-Questions

As Slash Commands

# .claude/commands/done-check.md
Review the work just completed and answer honestly:

1. Is the implementation complete per the original request?
2. Are there any TODOs, FIXMEs, or incomplete sections?
3. Are there obvious bugs or edge cases not handled?
4. Are there missing tests?
5. Does it match the spec/requirements?

If anything is incomplete, list the specific gaps.
Do not say "done" unless it's actually done.
# .claude/commands/bug-hunt.md
Analyze the code just written for bugs:

1. Logic errors (wrong conditions, off-by-one, etc.)
2. Edge cases not handled (empty, null, max values)
3. Race conditions or concurrency issues
4. Resource leaks (memory, connections, files)
5. Security vulnerabilities (injection, auth bypass)
6. Error handling gaps

For each bug found:
- File and line number
- Description of the bug
- How to trigger it
- Suggested fix
# .claude/commands/missing-tests.md
Analyze the code and identify missing test coverage:

1. Happy path cases not tested
2. Error cases not tested
3. Edge cases not tested
4. Integration points not tested
5. Invariants not verified

For each missing test:
- What should be tested
- Why it matters
- Draft the test

As Agent Prompts

# .claude/agents/self-reviewer.md
---
name: self-reviewer
description: Reviews agent work for completeness and correctness
tools: Read, Grep, Glob
model: sonnet
---

You review work completed by other agents (or yourself).

For each review:
1. Read the original request/spec
2. Read the implementation
3. Answer the meta-questions:
   - Is it actually done?
   - Are there bugs?
   - What's missing?
   - What could go wrong?

Be critical. Find problems. Don't rubber-stamp.

Recursive Agent Spawning

Meta-questions can spawn new agent sessions:

Main Agent: Implement feature X[Implementation complete]Main Agent: /done-checkSelf-Reviewer: "Found 3 gaps: A, B, C"
        ↓
Main Agent: Fix gap AMain Agent: Spawn sub-agent for gap BMain Agent: Spawn sub-agent for gap C[All gaps resolved]Main Agent: /done-checkSelf-Reviewer: "All complete"

Implementation with Claude Agent SDK

async function implementWithVerification(spec: string): Promise<Result> {
  // Initial implementation
  let result = await agent.run(`Implement: ${spec}`);

  // Recursive verification loop
  let iterations = 0;
  const maxIterations = 5;

  while (iterations < maxIterations) {
    // Ask meta-questions
    const review = await agent.run(`
      Review this implementation:
      ${result.code}

      Answer:
      1. Is it complete? (yes/no)
      2. Are there bugs? (list them)
      3. What's missing? (list gaps)
    `);

    if (review.isComplete && review.bugs.length === 0) {
      return result;
    }

    // Spawn sub-agents for each gap
    const fixes = await Promise.all([
      ...review.bugs.map(bug =>
        spawnAgent(`Fix bug: ${bug}`, result.code)
      ),
      ...review.gaps.map(gap =>
        spawnAgent(`Implement missing: ${gap}`, result.code)
      ),
    ]);

    // Merge fixes
    result = mergeResults(result, fixes);
    iterations++;
  }

  // Escalate to human if still not done
  return { ...result, needsHumanReview: true };
}

The Question Cascade

Different questions for different phases:

During Implementation

  • “Am I solving the right problem?”
  • “Is this the simplest approach?”
  • “What am I assuming?”

After Implementation

  • “Is this actually done?”
  • “Does it match the spec?”
  • “What did I miss?”

Before Commit

  • “Are there bugs?”
  • “Are there security issues?”
  • “What tests are missing?”

Before Deploy

  • “What could go wrong in production?”
  • “How will this behave under load?”
  • “What monitoring do we need?”

Stacking with Agent Swarms

Combine meta-questions with swarm patterns:

# .claude/commands/thorough-review.md
Launch 5 sub-agents to review this code, each asking:

Agent 1: "Are there bugs?" (logic focus)
Agent 2: "Are there security issues?" (security focus)
Agent 3: "What tests are missing?" (testing focus)
Agent 4: "What could fail in production?" (ops focus)
Agent 5: "Does this match the spec?" (correctness focus)

Aggregate findings, deduplicate, prioritize by severity.

Each agent brings a different perspective to the same meta-question.


The Recursive Improvement Loop

┌─────────────────────────────────────────────────────────────┐
                                                             
    ┌──────────┐    ┌──────────┐    ┌──────────┐            
       Do     │───▶│  Check   │───▶│   Fix                
      Work          (Meta         Gaps                
                  │Questions)│                          
    └──────────┘    └────┬─────┘    └────┬─────┘            
                                                           
                                                           
                    ┌─────────┐                             
                      Done?  │──────────┘                   
                      No                                   
                    └────┬────┘                              
                          Yes                               
                                                            
                    ┌─────────┐                              
                     Complete│                              
                    └─────────┘                              
                                                             
└─────────────────────────────────────────────────────────────┘

Quality Gate Meta-Questions

Build meta-questions into quality gates:

# .github/workflows/quality-gates.yml
jobs:
  implementation:
    steps:
      - run: claude "Implement feature X"

  meta-review:
    needs: implementation
    steps:
      - name: Done check
        run: claude "/done-check"

      - name: Bug hunt
        run: claude "/bug-hunt"

      - name: Missing tests
        run: claude "/missing-tests"

      - name: Aggregate issues
        run: ./scripts/aggregate-review.sh

      - name: Fix if needed
        if: steps.aggregate.outputs.issues > 0
        run: claude "Fix these issues: ${{ steps.aggregate.outputs.issues }}"

Key Insight

The best agents don’t just complete tasks—they question their own work and recursively improve until truly done.

Meta-questions are the difference between “agent said it’s done” and “agent verified it’s done.”


Related

Topics
Ai AgentsRecursive AlgorithmsSelf ImprovementTesting Automation

More Insights

Cover Image for Thought Leaders

Thought Leaders

People to follow for compound engineering, context engineering, and AI agent development.

James Phoenix
James Phoenix
Cover Image for Systems Thinking & Observability

Systems Thinking & Observability

Software should be treated as a measurable dynamical system, not as a collection of features.

James Phoenix
James Phoenix