prompts-gpt sweep
Multi-iteration execution engine that runs the same prompt N times, feeding each iteration's summary into the next for progressive refinement.
Usage
# Single file
prompts-gpt sweep [-f <path>] [-n <count>] [--agent <name>] [--model <name>]
# All sweep files
prompts-gpt sweep --all-sweeps [--sweep-strategy sequential|parallel] [-n <count>]
# Specific sweep files
prompts-gpt sweep --sweep-files <a,b,c> [--sweep-strategy sequential|parallel] [-n <count>]
When to Use
Use sweep for:
- Deep audits — Run a security or code quality audit multiple times, with each pass building on previous findings
- Progressive refinement — Each iteration receives a summary of what the last iteration accomplished
- Autonomous quality loops — Self-evaluation scoring can rate each iteration and stop early if quality thresholds are met
- Exhaustive checklists — Large audit files where one pass can't cover everything
Options
File Selection
| Flag | Description |
|---|---|
-f, --prompt-file <path> | Prompt file to sweep. Auto-detects sweeps if omitted. |
--all-sweeps | Run every file in .prompts-gpt/sweeps/. |
--sweep-files <list> | Comma-separated sweep paths, filenames, or names. |
--sweep-strategy <mode> | File execution: sequential or parallel. Default: sequential. |
--files-mode <mode> | Alias for --sweep-strategy. |
--file-concurrency <n> | Max files to run at once in parallel mode. |
Iteration Control
| Flag | Description |
|---|---|
-n, --iterations <n> | Number of iterations. Interactive default: 1. |
--parallel <n> | Run iterations in parallel batches (experimental). |
--iteration-timeout <secs> | Timeout per iteration. Default: 5400 (90 min). |
--max-retries <n> | Retries per iteration on spawn/timeout failure. Default: 2. |
--summary-lines <n> | Lines of summary extracted per iteration. Default: 40. |
Provider & Model
| Flag | Description |
|---|---|
--agent <name> | Provider profile. Default from config or router. |
--model <name> | Model override. |
--list-models | List available models for the selected provider. |
Execution
| Flag | Description |
|---|---|
--phase <name> | Phase label injected into the prompt. |
--sandbox <mode> | Codex sandbox mode. Default: workspace-write. |
--no-approve-mcps | Disable Cursor MCP auto-approval. |
--background | Cursor cloud agent mode. |
--permission-mode <mode> | Claude permission mode. Default: acceptEdits. |
--allow-destructive-git | Allow agents to run git stash/reset. |
Output & Safety
| Flag | Description |
|---|---|
--artifacts-dir <path> | Override artifacts directory. |
--run-id <id> | Explicit run ID. |
--max-run-dirs <n> | Max artifact directories to keep. Default: 20. |
--dry-run | Preview without executing. |
--quiet, -q | Suppress live logs (keep iteration headers). |
--silent | Suppress all output except errors. |
--non-interactive | Skip interactive prompts. |
--force-unlock | Release a stale sweep lock. |
--json | Machine-readable JSON output. |
How Sweep Works
Iteration Lifecycle
Iteration 1:
┌─────────────────────────┐
│ Original Prompt │ → Agent executes → Output + Summary
└─────────────────────────┘
Iteration 2:
┌─────────────────────────┐
│ Original Prompt │
│ + "Previous iteration │ → Agent executes → Output + Summary
│ summary: ..." │
└─────────────────────────┘
Iteration 3:
┌─────────────────────────┐
│ Original Prompt │
│ + "Previous iteration │ → Agent executes → Output + Summary
│ summary: ..." │
└─────────────────────────┘
Context Chaining
After each iteration, the sweep engine:
- Extracts a summary from the agent's output (last N lines or structured summary)
- Injects this summary into the next iteration's prompt
- The agent sees what was accomplished and continues from there
Pre-Flight Checks
Before running, sweep validates:
- Provider CLI is installed and accessible
- No existing sweep lock (prevents concurrent sweeps on the same file)
- Prompt file exists and is readable
- Configuration is valid
Lock Management
- A
.sweep.lockfile prevents concurrent sweeps on the same prompt - Locks include PID and timestamp for stale detection
- Use
--force-unlockto release stale locks - SIGTERM/SIGINT handlers automatically release locks
Self-Evaluation
Sweep files can include evaluation criteria in YAML frontmatter:
---
iterations: 3
eval:
criteria:
- correctness
- completeness
- code-quality
passThreshold: 0.7
---
After each iteration, the engine can score the output against these criteria and include the score in the summary.
Examples
Interactive mode
prompts-gpt sweep
Presents file picker, iteration count, provider, and model selection.
Explicit file and iterations
prompts-gpt sweep -f .prompts-gpt/sweeps/security-audit.md -n 5
All sweeps sequentially
prompts-gpt sweep --all-sweeps --sweep-strategy sequential -n 3
All sweeps in parallel
prompts-gpt sweep --all-sweeps --sweep-strategy parallel -n 2
Specific sweeps by name
prompts-gpt sweep --sweep-files design,research,security -n 2
Parallel iterations (experimental)
prompts-gpt sweep -f .prompts-gpt/sweeps/audit.md -n 6 --parallel 3
Runs 6 iterations in batches of 3 concurrently.
With model override
prompts-gpt sweep --model claude-sonnet-4-20250514
Dry run preview
prompts-gpt sweep -f .prompts-gpt/sweeps/tests.md -n 3 --dry-run
Sweep File Format
Sweep files are Markdown files stored in .prompts-gpt/sweeps/:
---
iterations: 3
eval:
criteria:
- correctness
- completeness
passThreshold: 0.7
---
# Security Audit
Review the entire codebase for security vulnerabilities.
Fix every issue found — do not just report.
## Checklist
- [ ] SQL injection
- [ ] XSS vulnerabilities
- [ ] CSRF protection
- [ ] Authentication bypass
YAML Frontmatter Fields
| Field | Type | Description |
|---|---|---|
iterations | number | Default iteration count for non-interactive runs |
eval.criteria | string[] | Scoring dimensions for self-evaluation |
eval.passThreshold | number | Score threshold (0.0–1.0) for passing |
Artifacts
.scripts/runs/
agent-YYYYMMDDHHMMSS-PID-HASH/
iteration-1/
raw-output.log
summary.md
meta.json
iteration-2/
raw-output.log
summary.md
meta.json
sweep-manifest.json # Overall sweep results
summary.md # Final combined summary
Sweep Result
{
ok: boolean;
iterations: SweepIterationResult[];
totalDurationMs: number;
provider: string;
model: string;
iterationsCompleted: number;
iterationsRequested: number;
evalScores?: SweepEvalScore[];
}
See Also
- Sweep vs Prompts Guide — Deep comparison
- run — Single-shot execution
- orchestrate — Multi-agent orchestration