Skip to main content

Ritualized AI agent workflows - multi-pass prompt pipelines for Cursor and beyond

Project description

macrocycle

Your StarCraft macro loop for code.

Ritualized AI agent workflows - multi-pass prompt pipelines for Cursor and beyond.

⚡ Why Macros?

  • Burn tokens, not time. Let AI iterate through analysis, planning, and implementation while you context-switch.
  • Scale horizontally. Spawn parallel agents — 10 errors in, 10 PRs out.
  • Artifacts you can audit. Every cycle saves outputs to disk. Review before merging.

📦 Installation

pipx install macrocycle

Or: pip install macrocycle / uv tool install macrocycle

🚀 Quick Start

cd your-project
macrocycle init

git checkout -b fix/your-issue
macrocycle run fix "Paste your error context here"

🔄 The Ritual

The default fix macro runs your agent through a structured loop:

🔍 impact    Analyze the problem deeply
     ↓
📋 plan      Create a concrete fix plan
     ↓
❌ reject    Force refinement (no hand-waving!)
     ↓
✅ approve   Human gate: review & approve
     ↓
🔨 implement Execute the plan, write code
     ↓
🔬 review    Self-review for bugs & edge cases
     ↓
✨ simplify  Clean up, follow conventions
     ↓
🚀 PR        Ship it with a clear description

Use --dry-run to preview the prompts before running:

macrocycle run fix "your error" --dry-run

🔁 Orchestration

Macrocycle is composable — pipe in data from any source, run in parallel, integrate with your toolchain.

Example: Batch-fix Sentry errors

Sentry is an error monitoring platform. This script pulls unresolved issues from the last 24h and spawns parallel agents to fix each one:

# Fix all new unresolved issues from the last 24h (with latest event)
set -euo pipefail
: "${SENTRY_AUTH_TOKEN:?}" "${SENTRY_ORG:?}" "${SENTRY_PROJECT:?}"
SENTRY_URL="${SENTRY_URL:-https://sentry.io}"
QUERY='is:unresolved age:-24h'

sentry-cli issues list -o "$SENTRY_ORG" -p "$SENTRY_PROJECT" --query "$QUERY" \
| awk 'NR>3 && $1 ~ /^[0-9]+$/ {print $1}' \
| while read -r issue_id; do
    [ -n "$issue_id" ] || continue
    git checkout -b "fix/sentry-$issue_id"
    macrocycle run fix "$(
      curl -sS -H "Authorization: Bearer $SENTRY_AUTH_TOKEN" \
        "$SENTRY_URL/api/0/organizations/$SENTRY_ORG/issues/$issue_id/"
      echo
      curl -sS -H "Authorization: Bearer $SENTRY_AUTH_TOKEN" \
        "$SENTRY_URL/api/0/organizations/$SENTRY_ORG/issues/$issue_id/events/?full=true&per_page=1"
    )" &
  done

wait

Each agent runs the full ritual autonomously. Batch review the PRs when ready.

Works with any issue tracker, log aggregator, or CI pipeline.

🛠 CLI Commands

macrocycle init                      # Initialize .macrocycle folder
macrocycle list                      # List available macros
macrocycle run <macro> <input>       # Run a macro
macrocycle run fix "..." --yes       # Skip gate approvals
macrocycle run fix "..." --until impact  # Stop after specific step

✏️ Custom Macros

Create your own workflows in .macrocycle/macros/:

{
  "macro_id": "review",
  "name": "Code Review",
  "engine": "cursor",
  "include_previous_outputs": true,
  "steps": [
    {
      "id": "analyze",
      "type": "llm",
      "prompt": "Analyze this code for issues:\n\n{{INPUT}}"
    },
    {
      "id": "confirm",
      "type": "gate",
      "message": "Apply suggested fixes?"
    },
    {
      "id": "fix",
      "type": "llm", 
      "prompt": "Apply the fixes identified above."
    }
  ]
}

Step types:

  • llm — Send prompt to agent, save output
  • gate — Pause for human approval (skip with --yes)

Template variables:

  • {{INPUT}} — User's original input
  • {{STEP_OUTPUT:step_id}} — Output from a previous step

📁 Artifacts

.macrocycle/
  macros/fix.json           # Workflow definitions
  cycles/                   # Execution history
    2026-01-15_fix_abc123/
      input.txt
      steps/01-impact.md
      steps/02-plan.md
      ...

🧑‍💻 Development

See docs/DEVELOPMENT.md for setup, testing, and releases.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

macrocycle-0.1.2.tar.gz (24.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

macrocycle-0.1.2-py3-none-any.whl (37.5 kB view details)

Uploaded Python 3

File details

Details for the file macrocycle-0.1.2.tar.gz.

File metadata

  • Download URL: macrocycle-0.1.2.tar.gz
  • Upload date:
  • Size: 24.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for macrocycle-0.1.2.tar.gz
Algorithm Hash digest
SHA256 419242593e42dd50ef83726f65d54031016a9a88b5edff1564638e6ffcff4afa
MD5 4f473781cba1d3770e1a04b6828b1a42
BLAKE2b-256 70d22f8f22408a9743c4d333aaf8aee7e10c125a044f7191a78ec97c69c19ff3

See more details on using hashes here.

Provenance

The following attestation bundles were made for macrocycle-0.1.2.tar.gz:

Publisher: publish.yml on MilanPecov/macrocycle

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file macrocycle-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: macrocycle-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 37.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for macrocycle-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5a6a76750fc74d3ba9c1a0db1df143931d683b1b8b2bb990c70d7f9ced8d8750
MD5 699d99f07dcfea2b2a63741c25e7d14b
BLAKE2b-256 b2faf322a1aa44b990d8eea1db16f42ee31cffad22bdfb211ee8846ad0836921

See more details on using hashes here.

Provenance

The following attestation bundles were made for macrocycle-0.1.2-py3-none-any.whl:

Publisher: publish.yml on MilanPecov/macrocycle

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page