Skip to content
Skills Library
AI & agents · Automation

ctx-loop

/ctx-loop

Generate a shell script for running AI tools in autonomous iteration loops. Use when setting up unattended iteration, headless agent runs, or CI-driven AI workflows.

Repository
ctx ↗
Licence
Apache-2.0
Last repository change
18.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 18.10.2026, without references to retired models or APIs.

Licence

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

What it does and when to use it

Generate a shell script for running AI tools in autonomous iteration loops. Use when setting up unattended iteration, headless agent runs, or CI-driven AI workflows.

Original author description

Generate a shell script for running AI tools in autonomous iteration loops. Use when setting up unattended iteration, headless agent runs, or CI-driven AI workflows.

How it works

  1. Before Generating
  2. When to Use
  3. When NOT to Use
  4. Usage Examples
  5. Flags
  6. Supported Tools
  7. Completion Signals
  8. Execution
  9. Safety Notes
  10. Quality Checklist
Original SKILL.md headings · 104 lines, 517 words
SKILL.md preview
---
name: ctx-loop
description: "Generate a shell script for running AI tools in autonomous iteration loops. Use when setting up unattended iteration, headless agent runs, or CI-driven AI workflows."
allowed-tools: Bash(ctx:*)
---

Generate a ready-to-use autonomous loop shell script.

## Before Generating

1. **Check for existing loop script**: look for `loop.sh` in the
   project root; confirm before overwriting
2. **Verify PROMPT.md exists**: the generated script defaults to
   reading `PROMPT.md`; if missing, ask the user what prompt file
   to use
3. **Verify the context directory exists**: the loop pattern depends
   on persistent context; run `ctx init` first if needed

## When to Use

- When setting up a project for autonomous iteration
- When the user wants to run unattended AI development
- When switching AI tools (e.g., Claude to Aider) and need a
  new loop script
- When customizing loop parameters (max iterations, completion
  signal, prompt file)

## When NOT to Use

- For interactive pair-programming sessions (just use the AI
  tool directly)
- When the user already has a working loop script and has not
  asked for changes
- When the project lacks a context directory and `PROMPT.md` (set
  those up first with `ctx init --ralph`)

## Usage Examples

```text
/ctx-loop
/ctx-loop --tool aider
/ctx-loop --prompt TASKS.md --max-iterations 10
/ctx-loop --completion SYSTEM_BLOCKED --output my-loop.sh
```

## Flags

| Flag               | Short | Default            | Purpose                         |
|--------------------|-------|--------------------|---------------------------------|
| `--prompt`         | `-p`  | `PROMPT.md`        | Prompt file the loop reads      |
| `--tool`           | `-t`  | `claude`           | AI tool: claude, aider, generic |
| `--max-iterations` | `-n`  | `0` (unlimited)    | Stop after N iterations         |
| `--completion`     | `-c`  | `SYSTEM_CONVERGED` | Signal that ends the loop       |
| `--output`         | `-o`  | `loop.sh`          | Output script filename          |

## Supported Tools

| Tool      | Command generated                    |
|-----------|--------------------------------------|
| `claude`  | `claude --print "$(cat <prompt>)"`   |
| `aider`   | `aider --message-file <prompt>`      |
| `generic` | Template stub for custom AI CLI      |

## Completion Signals

The loop watches AI output for these signals:

| Signal               | Meaning                              |
|----------------------|--------------------------------------|
| `SYSTEM_CONVERGED`   | All tasks complete; loop exits       |
| `SYSTEM_BLOCKED`     | Needs human input; loop exits        |
| `BOOTSTRAP_COMPLETE` | Initial scaffolding done; loop exits |

## Execution

```bash
ctx loop $ARGUMENTS
```

The command writes a shell script (default `loop.sh`) and makes
it executable. Report the generated path and how to run it:

```bash
chmod +x loop.sh   # already done by ctx loop
./loop.sh
```

## Safety Notes

- The generated script includes `set -e` and a 1-second sleep
  between iterations to prevent runaway loops
- `--max-iterations` is strongly recommended for first runs;
  suggest a reasonable default (e.g., 10) if the user omits it
- The script captures AI tool errors with `|| true` so one
  failed iteration does not kill the loop
- Autonomous agents benefit from explicit reasoning prompts in
  PROMPT.md: adding "think step-by-step before each change"
  to the iteration prompt significantly improves accuracy and
  reduces cascading mistakes in unattended runs

## Quality Checklist

Before reporting success, verify:
- [ ] Generated script exists at the output path
- [ ] Script is executable
- [ ] Prompt file referenced in the script actually exists
- [ ] If `--max-iterations 0`, user is aware it runs until
      a completion signal (warn them)

Versions

The database has no other skills named ctx-loop.

Identical content appears in 1 other GitHub folders. We show one copy with the highest score.

Database snapshot: 13.11.2026 · package version 9c46f115d495 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100lean-ctx-review
    Review how the lean-ctx ctx_* MCP tools performed in the current session and file upstream issues for confirmed problems. Use when the user asks to review/audit lean-ctx tool performance, says "lean-ctx review", asks why ctx_* tools failed or fell back to native tools, or wants…
  • 100super-ralph-wiggum
    Run Claude Code in autonomous iteration loops until task completion — PRD-based feature development, test coverage improvement, lint fixing, documentation generation, dataset creation, or framework migrations. Uses in-session loop mechanism with specialized templates. Triggers…
  • 100autonomous-loops
    Patterns and architectures for autonomous loops — from simple sequential pipelines to RFC-driven multi-agent DAG systems. Use when setting up autonomous development workflows, choosing the right loop architecture, or building CI/CD-style continuous development pipelines.
  • 100loop-designer
    Compile a goal into a durable, file-backed agent loop — a .loop/<name>/ charter any coding agent (Claude Code, Codex, Gemini, Grok) can execute unattended. Use when the user wants to "build a loop", "design a loop", "run X continuously/24-7", "make an agent keep working on Y",…
  • 100deepseek-harness
    Use when running, scripting, or extending DeepSeek Harness (dsh) 0.2.1 — npx @deepseek-ai/dsh web / dsh --profile, headless one-shot runs, the deepseek-harness-sdk Python DeepSeekHarness client, or Cordis plugins that export apply(ctx) and register tools with defineTool; also…
  • 100loop-readiness
    Review the readiness of a plan for an unattended/autonomous loop — checks whether it has enough feedforward guidance and feedback verification to run safely. Use when the user has a plan (or an idea) for a loop/agent that will run multiple iterations without a human checking…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.