build-agent-looplisted
Install: claude install-skill ysz7/specrun
# Build an Agent Loop
## When this applies
- "Build me an agent that can <do something with tools>"
- An LLM integration exists but has no tool-calling loop
- An existing loop has no budgets, no truncation, or no traces
## Do not use for
- Fixed, known step sequences → build a chain instead (see `../blueprints/blueprints/prompt-chaining.md`)
- Adding *one* tool to an existing working loop → use `design-agent-tools`
- Diagnosing why an existing agent failed → use `debug-agent-trajectory`
## Inputs to collect first
| Input | Why needed | Default if unspecified |
|---|---|---|
| Task the agent performs | Determines tools and stop condition | Ask — do not guess |
| Language / framework | Code shape | Python + the provider's official SDK |
| Available tools or APIs | The toolset | Start with 3; add only what the task needs |
| Any irreversible actions? | Decides whether gating is required | Assume yes if anything writes outside a sandbox |
| Latency / cost ceiling | Sets `max_steps` and model tier | 20 steps, 300 s, frontier model |
If running unattended, take the defaults and state them at the top of the output.
## Procedure
### Step 1 — Write the stop condition before anything else
State, in one sentence, what "done" looks like. Put it verbatim in the system prompt.
An agent without an explicit terminal condition runs until the step cap.
> "You are done when you have <X>. Reply with plain text and no tool call."
**Stop condition:** the sentence exists and is unambigu