Do not ask an agent to "build an app". Ask it to "write the database schema."
AI models have a context window and a limited ability to plan 20 steps ahead. If you give them a monolithic task (e.g. "Migrate our database"), they will hallucinate or get stuck.
You must Decompose the task into verifiable, atomic steps. Instead of one massive prompt, you generate a Build Plan. You insert Human Review Gates between critical steps (e.g., verifying the schema is correct before letting the AI write the migration scripts).
# The workflow for complex tasks:
# 1. Planning Phase (Agent 1)
prompt = "Analyze the repo and write a markdown checklist of steps to migrate."
plan = agent.generate(prompt)
# 2. Human Review (YOU)
# You review the plan, modify steps, and ensure the schema translation is correct.
# 3. Execution Phase (Agent 2)
for step in plan:
# We pass ONLY the current step and the overall context
execute_prompt = f"Implement step: {step}. Context: {repo}"
agent.generate(execute_prompt)
# Allows for verifiable checkpoints!