Skip to main content

A quality-assurance engine for LLM-generated code

Project description

AgentGuard

PyPI version Python License: MIT Downloads CI

Agent-native quality engine for LLM code generation. AgentGuard provides structured guidance to your AI agent โ€” it never calls an LLM itself.

878+ monthly installs ยท Explore Marketplace ยท Documentation


๐ŸŽฌ Video Tutorials

New to AgentGuard? Watch the demo series:

# Video Duration
00 What is AgentGuard? โ€” Explainer 3:54
01 Installation & Setup from Zero 3:44
02 Create a Project from Scratch with AI ~6 min
03 Automatic Documentation โ€” ADR, PRD & Dev Guide ~5 min
04 Migration: Spaghetti โ†’ CQRS Architecture ~6 min

๐Ÿ‡ช๐Ÿ‡ธ Spanish versions also available โ€” see full playlist


Why AgentGuard

AI agents generate code fast. But without structure, they hallucinate imports, skip error handling, and produce inconsistent architecture.

AgentGuard gives your agent a disciplined framework โ€” without replacing it. It's the quality layer between your AI and your codebase.

What It Does

AgentGuard is an MCP server that gives your AI agent (Claude, GPT, Gemini, etc.) a disciplined process for generating production-ready code:

  1. Skeleton โ†’ file tree with responsibilities
  2. Contracts & Wiring โ†’ typed stubs with import connections
  3. Logic โ†’ function-by-function implementation
  4. Challenge โ†’ self-review against quality criteria
  5. Validate โ†’ static analysis (syntax, lint, types, imports)

Your agent does the thinking. AgentGuard provides the framework.

Installation

pip install rlabs-agentguard

That's it. One command, no extras, no API keys needed.

Configure Your IDE

Claude Desktop / Claude Code

Add to your MCP config:

{
  "mcpServers": {
    "agentguard": {
      "command": "agentguard-mcp"
    }
  }
}

Cursor / Windsurf

Add to .cursor/mcp.json or equivalent:

{
  "mcpServers": {
    "agentguard": {
      "command": "agentguard-mcp"
    }
  }
}

Python (direct)

python -m agentguard  # starts MCP server on stdio

Quick Example โ€” What You Get

Ask your agent: "Build a REST API for task management using AgentGuard"

AgentGuard's skeleton tool returns a structured file tree:

src/
โ”œโ”€โ”€ app.py              # FastAPI application entry point
โ”œโ”€โ”€ config.py           # Environment and app configuration
โ”œโ”€โ”€ models/
โ”‚   โ””โ”€โ”€ task.py         # Task SQLAlchemy model
โ”œโ”€โ”€ routers/
โ”‚   โ””โ”€โ”€ tasks.py        # CRUD endpoints for /tasks
โ”œโ”€โ”€ services/
โ”‚   โ””โ”€โ”€ task_service.py # Business logic layer
โ””โ”€โ”€ tests/
    โ””โ”€โ”€ test_tasks.py   # Endpoint + service tests

Then contracts_and_wiring generates typed stubs with all imports wired:

# src/routers/tasks.py
from fastapi import APIRouter, Depends, HTTPException
from ..services.task_service import TaskService
from ..models.task import Task, TaskCreate, TaskUpdate

router = APIRouter(prefix="/tasks", tags=["tasks"])

@router.get("/", response_model=list[Task])
async def list_tasks(service: TaskService = Depends()) -> list[Task]: ...

@router.post("/", response_model=Task, status_code=201)
async def create_task(payload: TaskCreate, service: TaskService = Depends()) -> Task: ...

Your agent fills in the logic. AgentGuard ensures the structure is right from the start.

Tools

Agent-Native (structured guidance โ€” no API key)

Tool Purpose
skeleton L1: file tree with responsibilities
contracts_and_wiring L2+L3: typed stubs with imports (saves ~15K tokens vs separate calls)
contracts L2 only: typed function/class stubs
wiring L3 only: import and call-chain connections
logic L4: implement one function body
get_challenge_criteria Self-review criteria for an archetype
digest Compact project summary for efficient review
debug Structured debugging protocol
migrate Migration plan with compatibility checks

Utility

Tool Purpose
validate Mechanical code checks (syntax, lint, types, structure)
list_archetypes List all available project archetypes
get_archetype Get detailed archetype configuration
reload_archetypes Pick up newly installed archetypes
trace_summary Get cost & token tracking summary
docs Get AgentGuard documentation on any topic
update_agentguard Update to the latest version from PyPI

Built-In Archetypes

Archetype Tech Stack
api_backend Python + FastAPI (production)
library Python reusable package (production)
cli_tool Python CLI with subcommands
react_spa TypeScript + React SPA (production)
web_app Python + TypeScript full-stack (production)
script Python one-off automation
debug_backend Python/FastAPI debugging protocol
debug_frontend React/TypeScript debugging protocol

+ 61 community archetypes on the AgentGuard Marketplace โ€” browse, install, and publish your own.

Marketplace

Install community archetypes:

# From the AgentGuard marketplace (agentguard.rlabs.cl)
# Use the reload_archetypes tool after installing

How It Works

AgentGuard is agent-native: every tool returns structured prompts and criteria that your AI agent processes. The tool never calls an external LLM.

Your Agent (Claude, GPT, etc.)
    โ”‚
    โ”œโ”€โ”€ calls skeleton(spec, archetype) โ”€โ”€โ”€โ”€โ”€โ†’ returns L1 file tree prompt
    โ”œโ”€โ”€ calls contracts_and_wiring(spec, skeleton) โ†’ returns L2+L3 stubs prompt
    โ”œโ”€โ”€ calls logic(file, function) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ†’ returns L4 implementation prompt
    โ””โ”€โ”€ calls get_challenge_criteria() โ”€โ”€โ”€โ”€โ”€โ”€โ†’ returns review criteria
    โ””โ”€โ”€ calls validate(files) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ†’ returns static analysis results

The agent reads the prompt, generates the code, validates it, and loops back if criteria aren't met. AgentGuard provides the structure โ€” your agent provides the intelligence.

Development

pip install -e ".[dev]"
pytest tests/
ruff check agentguard/

Latest Release

See CHANGELOG.md for the full version history.

Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines on:

  • Setting up your dev environment
  • Creating custom archetypes
  • Submitting pull requests

Looking for a place to start? Check out issues labeled good first issue.

License

MIT โ€” see LICENSE.

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

rlabs_agentguard-0.12.2.tar.gz (133.5 kB view details)

Uploaded Source

Built Distribution

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

rlabs_agentguard-0.12.2-py3-none-any.whl (150.7 kB view details)

Uploaded Python 3

File details

Details for the file rlabs_agentguard-0.12.2.tar.gz.

File metadata

  • Download URL: rlabs_agentguard-0.12.2.tar.gz
  • Upload date:
  • Size: 133.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rlabs_agentguard-0.12.2.tar.gz
Algorithm Hash digest
SHA256 45e39df1cc0e769a4c35b2b2b2fdb54ad0d9f38fa92dbec103f38f4c9bcb1fa2
MD5 5f68712f92628f2fe6ce76f9d1239355
BLAKE2b-256 3a1c1d1171d549812963f9b43e246dc419787b564a4dffdfdbf445bbeedb9e59

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlabs_agentguard-0.12.2.tar.gz:

Publisher: publish-pypi.yml on rlabs-cl/agentguard-lib

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

File details

Details for the file rlabs_agentguard-0.12.2-py3-none-any.whl.

File metadata

File hashes

Hashes for rlabs_agentguard-0.12.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3b8b39ec89497ed92a1db46c8efebdbbde831e336b450aa554f1ede2de59ca18
MD5 c2eabb356dbfc4d98f9d534b2f6d6d4c
BLAKE2b-256 c2f0d1ea769478394025e88ff6bff18191f6b0f876ebf42be1eefcb27e4f7391

See more details on using hashes here.

Provenance

The following attestation bundles were made for rlabs_agentguard-0.12.2-py3-none-any.whl:

Publisher: publish-pypi.yml on rlabs-cl/agentguard-lib

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