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.
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.
- One spec to read โ
llms.txtorllms-full.txtcovers everything - One config to edit โ
corral.yamlis the single source of truth - --json on every command โ structured output, numeric exit codes, no screen-scraping
- CORRAL.md after init โ project-specific guide the agent reads for subsequent changes
- Idempotent commands โ safe to re-run on failure; agents can retry without side effects
- Self-diagnosing errors โ every error JSON includes a
"fix"field telling the agent exactly what to do
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:
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)
## 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)
## 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.
# 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
- Homepage prompts: use the copy-paste starter prompts from the homepage/quickstart to instruct any coding agent.
llms-agent-prompt.md: generated template with project-specific instructions aftercorral init..corral/agent-checklist.json: machine-readable completion checklist consumed bycorral doctor.
Supported Agents
Any agent that can run shell commands and read markdown can use Corral. Here's how to set up each major agent:
Native Corral skill. OpenClaw knows the full CLI and YAML schema without needing llms.txt.
Setup
Or add to your workspace AGENTS.md โ OpenClaw reads it on every session.
Point it at llms.txt and it handles everything. Best results with AGENTS.md context.
Setup
Or in your prompt
The --json flag on every command makes Codex integration seamless. No output parsing.
Setup
Add to .cursorrules for persistent context in every Cursor session on this project.
Setup
Add Corral context to Windsurf's project rules or include in your system prompt.
Setup
Use /read to add llms.txt or llms-full.txt to Aider's context. Include CORRAL.md after init.
Setup
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
Example Prompts
These are prompts that work well with Corral-aware agents. The more specific you are, the better the output.
Basic auth setup
Add user authentication to this app using Corral.
Email magic link + Google OAuth.
After setup, validate with corral validate --json.
Full SaaS billing
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
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
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:
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 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
# 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
// 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
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.
Full agent script
#!/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.
| Command | Run twice? | Behavior |
|---|---|---|
corral init | Safe | Skips files that already exist; updates corral.yaml |
corral add feature X | Safe | No-op if feature X already defined |
corral add provider google | Safe | No-op if google already in providers list |
corral stripe push | Safe | Updates existing Stripe products (no duplicates) |
corral seed | Safe with --reset | By default, skips existing test users |
corral validate | Always safe | Read-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.
corral_analyze, corral_init, corral_add_feature,
corral_add_plan, corral_validate, corral_stripe_push,
and more as MCP tools with full JSON schemas.
{
"mcpServers": {
"corral": {
"command": "npx",
"args": ["@corral/mcp"],
"env": {
"CORRAL_CONFIG": "./corral.yaml"
}
}
}
}
Design Goals
The agent-native design has four principles:
- Discover without reading docs โ
/api/llms.txtandCORRAL.mdgive agents everything they need about a specific project. - Parse without screen-scraping โ Every command has
--jsonmode with consistent structure and exit codes. - Act without side effects โ
corral analyzeand--dry-runflags let agents understand state before making changes. - Recover without human help โ
corral doctordiagnoses problems and suggests fixes;corral rollbackundoes changes. Every error JSON includes a"fix"field.