macrocycle
Closed-loop AI agent workflows.
Phase-based execution with validation feedback -- each phase is a control loop where the agent iterates until tests pass, linters are clean, or whatever your definition of done is.
Why?
AI agents are powerful but undisciplined. They rush to implement, skip analysis, and produce brittle code. Macrocycle fixes this by forcing your agent through structured phases with automated validation feedback loops.
The control loop is the product. Integrations (Sentry, GitHub, etc.) are left to the IDE or tools like Claude Code.
Installation
pipx install macrocycle
Quick Start
macrocycle init # Initialize .macrocycle/
macrocycle run fix "ValueError in process_request" # Run workflow
macrocycle run fix "..." --until analyze # Stop after a phase
macrocycle list # List workflows
macrocycle status # Latest run info
How It Works
Each workflow is a graph of phases. Each phase is a closed-loop control system:
Phase = Control Loop
┌──────────┐ ┌──────────┐ ┌──────────┐
│ Setpoint │───>│Controller│───>│ Actuator │
│(success │ │(Phase │ │(AI Agent) │
│ criteria)│ │Executor) │ └─────┬─────┘
└──────────┘ └────┬─────┘ │
│ ┌────▼─────┐
┌────▼─────┐ │ Plant │
│ Error │<────│(Codebase)│
│ Signal │ └────┬─────┘
└──────────┘ ┌────▼─────┐
^ │ Sensor │
└───────────│(pytest, │
│ ruff...) │
└──────────┘
- Execute steps (LLM prompts, shell commands)
- Validate via a shell command (the sensor)
- If validation fails, feed the error back into the next iteration
- Repeat until convergence or iteration budget exhausted
- Route to next phase
Workflow Definition
Workflows live in .macrocycle/workflows/ as JSON:
{
"id": "fix",
"name": "Fix Issue",
"agent": {"engine": "cursor"},
"phases": [
{
"id": "analyze",
"steps": [{"id": "impact", "type": "llm", "prompt": "Analyze: {{INPUT}}"}],
"on_complete": "implement"
},
{
"id": "implement",
"steps": [
{"id": "code", "type": "llm", "prompt": "Implement: {{PHASE_OUTPUT:analyze}}"},
{"id": "test", "type": "command", "command": "pytest --tb=short"}
],
"validation": {"command": "pytest -q"},
"max_iterations": 5,
"context": ["analyze"],
"on_complete": "review"
},
{
"id": "review",
"steps": [{"id": "review", "type": "llm", "prompt": "Review changes..."}],
"validation": {"command": "pytest && ruff check ."},
"max_iterations": 3,
"context": ["implement"]
}
]
}
Step types: llm (AI prompt) / command (shell command)
Variables: {{INPUT}} / {{PHASE_OUTPUT:id}} / {{STEP_OUTPUT:id}} / {{ITERATION}} / {{VALIDATION_OUTPUT}}
Agent config cascade: Workflow -> Phase -> Step (use cheaper models for iteration-heavy phases)
Artifacts
.macrocycle/
workflows/fix.json
runs/
20260312_143052_fix/
input.txt
manifest.json # Checkpoint for crash recovery
analyze/output.md
implement/output.md
review/output.md
Metadata
Release files for macrocycle 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| macrocycle-0.4.0.tar.gz | 26.6 kB | With provenance | Details for macrocycle-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| macrocycle-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for macrocycle-0.4.0-py3-none-any.whl |
Total release size: 68.2 kB
Release files / macrocycle-0.4.0.tar.gz
| Download URL | macrocycle-0.4.0.tar.gz |
|---|---|
| Size | 26.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b928b539be81cdc9ac78efc81de7c18da929ddf86c8915777da795a7ebe2def0
|
|
BLAKE2b-256 checksum How to use checksums |
1a420d68fa48db96c12fa8440face863c0d9ac5c7e8f1b644035a93d5d038bdc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 12, 2026.
Transparency logRelease files / macrocycle-0.4.0-py3-none-any.whl
| Download URL | macrocycle-0.4.0-py3-none-any.whl |
|---|---|
| Size | 41.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1c8716999a430ec34973f7580bd408ee0e3fd16bbb6204328143ccff472aa90c
|
|
BLAKE2b-256 checksum How to use checksums |
8138ddfb07e582eb5d1b6153b4a90b7c5944dd5071aeee3fbce4d0a0ccbb9a11
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 12, 2026.
Transparency logSecurity for macrocycle 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for macrocycle-0.4.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 12, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.