Agent Integration

Corral is built for AI coding agents. Point your agent here, tell it what you need, and it adds login, Stripe billing, and feature gating to your app โ€” in one conversation, with no human touching auth code.

TL;DR for agents
Read llms.txt or llms-full.txt, run npm create corral@latest then corral init, edit corral.yaml, run corral validate. Done. The app has auth + payments.

Why Corral is Agent-Native

Auth + billing integration is one of the hardest things for AI agents to get right with traditional libraries. Too many files, too many wiring decisions, too much tribal knowledge that lives in blog posts rather than docs.

Corral solves this by making the entire auth + billing topology declarative: one YAML file, one CLI, structured JSON output on every command. An agent can read the spec, generate the config, and wire up an entire auth stack without ambiguity.

Give Your Agent Corral Context

Before your agent can use Corral, it needs to know Corral exists and what it does. Here are the four ways to give your agent that context, depending on your setup:

Option 1: Paste the full URL (any agent)

The simplest approach. Give your agent the exact deployed URL:

prompt
Read: https://corral.llamafarm.dev/llms.txt
Then add auth and Stripe billing to this app.
Free tier and Pro at $29/mo. Use Google login.

Option 2: Add to AGENTS.md (Claude Code / OpenClaw)

AGENTS.mdmarkdown
## Auth + Payments

This project uses Corral for auth, Stripe billing, and feature gating.
Corral spec: https://corral.llamafarm.dev/llms.txt
Full reference: llms-full.txt

When asked to add auth or payments:
1. Read CORRAL.md (if it exists) for project-specific context
2. Otherwise, run: npm create corral@latest
then corral init
3. Edit corral.yaml with the requested plans/features
4. Run: corral validate --json

Option 3: Add to .cursorrules (Cursor)

.cursorrulestext
## Auth + Payments (Corral)

This project uses Corral for auth + Stripe billing.
Read: https://corral.llamafarm.dev/llms.txt for the full spec.

- All auth/billing config lives in corral.yaml
- To add a feature gate: corral add feature <name> --plans <list> --gate <mode>
- To add a plan: corral add plan <name> --price <n>
- To sync Stripe: corral stripe push --json
- To validate: corral validate --json (exit 0 = deploy-ready)

Option 4: OpenClaw Skill (first-class support)

Corral ships as an OpenClaw skill. When installed, OpenClaw knows Corral's full CLI, understands the YAML schema, and can make changes interactively as you describe what you want.

bash
# Install the Corral skill in OpenClaw
openclaw skill add corral

# Then just tell OpenClaw what you want:
# "Add Google auth and a $29/mo Pro plan with AI features gated"

Copy-paste prompts and agent files

Supported Agents

Any agent that can run shell commands and read markdown can use Corral. Here's how to set up each major agent:

๐Ÿฆ™
OpenClaw
First-class

Native Corral skill. OpenClaw knows the full CLI and YAML schema without needing llms.txt.

Setup

openclaw skill add corral

Or add to your workspace AGENTS.md โ€” OpenClaw reads it on every session.

๐Ÿค–
Claude Code
Excellent

Point it at llms.txt and it handles everything. Best results with AGENTS.md context.

Setup

# Add to AGENTS.md: Corral spec: https://corral.llamafarm.dev/llms.txt

Or in your prompt

Read: https://corral.llamafarm.dev/llms.txt then add auth + billing.
โšก
Codex
Great

The --json flag on every command makes Codex integration seamless. No output parsing.

Setup

# Add to AGENTS.md or pass in system prompt: Auth/payments: use Corral (llms.txt) Always use --json flag on corral commands.
๐ŸŽฏ
Cursor
Great

Add to .cursorrules for persistent context in every Cursor session on this project.

Setup

# .cursorrules Auth + payments: Corral. Read: https://corral.llamafarm.dev/llms.txt Config: corral.yaml | Validate: corral validate --json
๐ŸŒŠ
Windsurf
Good

Add Corral context to Windsurf's project rules or include in your system prompt.

Setup

# Project rules / system prompt: This project uses Corral for auth + billing. Spec: https://corral.llamafarm.dev/llms.txt
โŒจ๏ธ
Aider
Good

Use /read to add llms.txt or llms-full.txt to Aider's context. Include CORRAL.md after init.

Setup

/read https://corral.llamafarm.dev/llms.txt /read CORRAL.md # after corral init
๐Ÿ”ง
Any Agent
Supported

If it can run CLI commands and read markdown, it can use Corral. Just provide the full URL, e.g. https://corral.llamafarm.dev/llms.txt.

Universal setup

Read llms-full.txt for the Corral spec. All CLI commands support --json. Exit 0 = success, 1 = error.

Example Prompts

These are prompts that work well with Corral-aware agents. The more specific you are, the better the output.

Basic auth setup

prompt
Add user authentication to this app using Corral.
Email magic link + Google OAuth.
After setup, validate with corral validate --json.

Full SaaS billing

prompt
Add auth and Stripe billing to this app using Corral.

Plans:
- Free: $0/mo โ€” basic features, 500 API calls/month
- Pro: $29/mo โ€” all features, 10k API calls/month, 14-day trial

Auth: Google OAuth + email magic link

Gate the "ai_analysis" feature to Pro plan with blur effect.

After setup run corral validate --json and show me the output.

Adding a feature gate

prompt
Read CORRAL.md then add a feature gate for "advanced_export".
Available on Pro and Enterprise plans. Use "block" gate mode.
Run corral validate --json when done.

Adding a new plan

prompt
Add an "Enterprise" plan to Corral at $199/mo (annual only).
It should include all Pro features plus "sso" and "audit_log".
Sync to Stripe after. Show me the Stripe product IDs.

Full Example Conversation

Here's what it looks like when a human asks an agent to add auth with Google login and a $29/mo Pro plan:

You: Add auth to this Next.js app. I want Google login and email magic links. Free tier and Pro at $29/mo. Pro users get access to the AI dashboard feature. Use Corral โ€” read llms.txt first.
Agent: Reading Corral spec from llms.txt...
โ†’ fetch llms.txt
โ† [full spec loaded, 9-command workflow understood]
Agent: Got it. Analyzing the project first, then scaffolding Corral.
โ†’ corral analyze --json
โ† { "framework": "nextjs", "router": "app", "db": "prisma", "corral_installed": false }
โ†’ corral init --yes --json
โ† { "files_created": ["corral.yaml", "src/app/api/auth/[...corral]/route.ts", "CORRAL.md", ...] }
โ†’ corral add provider google --json
โ† { "status": "ok", "result": { "provider": "google" } }
โ†’ corral add provider email --magic-link --json
โ† { "status": "ok", "result": { "provider": "email", "magic_link": true } }
โ†’ corral add plan pro --price 29 --trial 14 --json
โ† { "status": "ok", "result": { "plan": "pro", "price": 29 } }
โ†’ corral add feature ai_dashboard --plans pro --gate blur --json
โ† { "status": "ok", "result": { "feature": "ai_dashboard", "gate": "blur" } }
โ†’ corral stripe push --json
โ† { "status": "ok", "result": { "prices": { "pro": "price_1Ov9mR2xK9mN" } } }
โ†’ corral validate --strict --json
โ† { "status": "ok", "checks": { "all": "pass" }, "errors": [] }
Agent: Done. Here's what was set up: โœ“ Google OAuth + email magic link configured โœ“ Free plan (unlimited) + Pro plan ($29/mo, 14-day trial) โœ“ AI Dashboard feature gated to Pro with blur effect โœ“ Stripe plans synced (Pro price ID: price_1Ov9mR2xK9mN) โœ“ All validation checks pass Next steps: - Add GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET to .env.local - Add STRIPE_SECRET_KEY and STRIPE_WEBHOOK_SECRET to .env.local - Test at localhost:3000/login

CORRAL.md โ€” The Project Guide

After corral init, a CORRAL.md file is created in your project root. This file is designed to be included in your agent's context for all subsequent Corral-related changes.

Tell your agent to read CORRAL.md before making any auth or billing changes. It contains project-specific paths, active features, active plans, and common commands โ€” exactly what an agent needs.

CORRAL.md โ€” example for a Next.js appmarkdown
# Corral in MySaaSApp

Corral v0.4.1 ยท Next.js 14 (App Router) ยท PostgreSQL (Prisma)

## Auth Routes

- Auth handler:    src/app/api/auth/[...corral]/route.ts
- Billing handler: src/app/api/billing/[...corral]/route.ts
- Admin page:      src/app/admin/page.tsx
- Login page:      /api/auth/signin (auto-generated)

## Active Features

| Feature       | Plans                  | Gate     |
|---------------|------------------------|----------|
| basic_access  | free, pro              | (none)   |
| ai_dashboard  | pro                    | blur     |

## Active Plans

| Plan        | Price | Stripe Product     |
|-------------|-------|--------------------|
| free        | $0    | (none)             |
| pro         | $29   | prod_R2xK9mN2aLp   |

## Adding a new feature

corral add feature <name> --plans <list> --gate <mode>

## Adding a new plan

corral add plan <name> --price <n> --interval month
corral stripe push  # sync to Stripe

## Testing auth locally

corral seed --count 3 --json
npm run dev
# Then sign in at http://localhost:3000/api/auth/signin

## Environment variables required

CORRAL_SECRET, DATABASE_URL, STRIPE_SECRET_KEY,
STRIPE_WEBHOOK_SECRET, GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, SMTP_URL

Keep CORRAL.md current

bash
# CORRAL.md is auto-updated after every corral add command
corral add feature advanced_export --plans pro --gate block
# โ†‘ CORRAL.md updated: advanced_export row added to features table

# Force regenerate from current corral.yaml state:
corral llms-txt --update

--json Flag โ€” Structured Output for Agents

Every CLI command accepts --json and returns structured output. Exit code 0 = success, 1 = error with details. Agents should always use --json.

Standard response envelope

json
// Success
{
  "status": "ok",
  "command": "corral add feature",
  "result": { ... },     // command-specific data
  "warnings": [],
  "next_steps": ["corral stripe push", "corral validate"]
}

// Error โ€” always includes a "fix" field telling agents what to do
{
  "status": "error",
  "command": "corral validate",
  "error": {
    "code": "ENV_MISSING",
    "message": "STRIPE_SECRET_KEY is not set",
    "fix": "Add STRIPE_SECRET_KEY=sk_test_... to .env.local"
  }
}

Using --json in agent code

python
import subprocess, json

def corral(*args):
    result = subprocess.run(
        ["corral", *args, "--json"],
        capture_output=True, text=True
    )
    data = json.loads(result.stdout)
    if result.returncode != 0:
        raise RuntimeError(f"{data['error']['message']} โ€” Fix: {data['error']['fix']}")
    return data

# Agent workflow:
analysis = corral("analyze")
print(f"Framework: {analysis['result']['framework']}")

result = corral("init", "--yes")
for step in result["next_steps"]:
    print(f"Next: {step}")

The 9-Command Workflow

This is the canonical sequence an agent uses to add full auth + billing + gating to a bare Next.js app. It's idempotent โ€” run it twice and it's fine.

1
corral analyze --json
Read-only. Detect framework, database, existing auth. Parse JSON to decide what to do next.
2
corral init --yes --json
Scaffold everything: corral.yaml, route handlers, components, CORRAL.md. Non-interactive.
3
corral add provider google --json
Add Google OAuth. Updates corral.yaml and generates callback route.
4
corral add plan pro --price 29 --json
Define paid plan. Updates corral.yaml only โ€” Stripe sync happens in step 7.
5
corral add feature ai_dashboard --plans pro --gate blur --json
Define a feature gate. YAML only โ€” no code change needed.
6
corral add meter api_calls --free 500 --pro 10000 --overage block --json
Add a usage meter with per-plan limits.
7
corral stripe push --json
Sync plans to Stripe. Creates Products, Prices, registers webhook. Returns price IDs.
8
corral validate --strict --json
Verify the entire config: env vars, DB connection, Stripe sync, feature consistency. Exit 0 = deploy-ready.
9
corral seed --count 3 --json
Create test users (one per plan) for local testing. Returns user IDs and credentials.

Full agent script

bash
#!/bin/bash
# Agent: add Corral auth + billing (run this after reading llms.txt)
set -e

# 1. Understand the project
ANALYSIS=$(corral analyze --json)
echo "Framework: $(echo $ANALYSIS | jq -r '.result.framework')"

# 2. Scaffold
corral init --yes --json | jq '.files_created[]'

# 3-6. Add providers, plans, features, meters
corral add provider google --json
corral add provider email --magic-link --json
corral add plan pro --price 29 --trial 14 --json
corral add feature ai_dashboard --plans pro --gate blur --json
corral add meter api_calls --free 500 --pro 10000 --overage block --json

# 7. Stripe sync
STRIPE=$(corral stripe push --json)
echo "Pro price ID: $(echo $STRIPE | jq -r '.result.prices.pro')"

# 8. Validate โ€” exit non-zero on any error
corral validate --strict --json

# 9. Seed test users
SEED=$(corral seed --count 1 --json)
echo "Test user: $(echo $SEED | jq -r '.result.users[0].email')"

echo "โœ“ Auth + payments installed. Login at localhost:3000/login"

Idempotency

All corral add commands are idempotent. Running them twice produces the same result as running them once. This is critical for agents that may retry on failure.

CommandRun twice?Behavior
corral initSafeSkips files that already exist; updates corral.yaml
corral add feature XSafeNo-op if feature X already defined
corral add provider googleSafeNo-op if google already in providers list
corral stripe pushSafeUpdates existing Stripe products (no duplicates)
corral seedSafe with --resetBy default, skips existing test users
corral validateAlways safeRead-only check

MCP Integration (Planned)

Corral will ship an MCP (Model Context Protocol) server that exposes all CLI commands as MCP tools. This allows agents to use Corral through standard MCP tooling rather than shell subprocess calls.

Coming in v0.2
The MCP server is planned for v0.2. It will expose: corral_analyze, corral_init, corral_add_feature, corral_add_plan, corral_validate, corral_stripe_push, and more as MCP tools with full JSON schemas.
mcp.json (future)json
{
  "mcpServers": {
    "corral": {
      "command": "npx",
      "args": ["@corral/mcp"],
      "env": {
        "CORRAL_CONFIG": "./corral.yaml"
      }
    }
  }
}

Design Goals

The agent-native design has four principles:

  1. Discover without reading docs โ€” /api/llms.txt and CORRAL.md give agents everything they need about a specific project.
  2. Parse without screen-scraping โ€” Every command has --json mode with consistent structure and exit codes.
  3. Act without side effects โ€” corral analyze and --dry-run flags let agents understand state before making changes.
  4. Recover without human help โ€” corral doctor diagnoses problems and suggests fixes; corral rollback undoes changes. Every error JSON includes a "fix" field.