RepoGuard
Generates a tailored .github/copilot-instructions.md file that injects repository-specific architectural rules and guardrails into GitHub Copilot's context to prevent AI code rot.
🛡️ RepoGuard
New in v1.7.0: Rust panic safety, expanded secret detection, and MCP Tools + Resources + Prompts.
🎮 Try it in your browser: RepoGuard Interactive Playground — Audit code snippets in real-time with zero install.
⚡ The Problem
AI coding assistants (Cursor, GitHub Copilot, Claude Code, Windsurf) write 300 lines of code in seconds. However, without strict repository guardrails, they frequently introduce AI Code Rot:
Bypass Architectural Layers: Run raw database queries (Prisma, Drizzle, SQLAlchemy, GORM, SQLx, Diesel) directly inside UI components or HTTP handlers.
Reinvent Existing Helpers: Write duplicate date/string utilities instead of importing from
/utilsor shared packages.Escape Type Safety & Error Handling: Scatter
: anyin TypeScript, discard errors with_ = errin Go, or use panic-prone.unwrap()in Rust production code.Leak Sensitive Secrets: Hardcode AI/cloud provider tokens, embed database credentials in connection URLs, or expose secrets with the
NEXT_PUBLIC_prefix.
RepoGuard acts as an automated architecture supervisor: it generates strict, customized .cursorrules, CLAUDE.md, and .windsurfrules context files, verifies pre-commit diffs in ~12ms, runs an MCP server with Tools, Resources, and Prompts, and performs inline audits on every Pull Request.
Related MCP server: vibelogic
🚀 Quickstart
Run directly in any repository (zero installation required):
npx repoguard-rules initOr install globally:
npm install -g repoguard-rules
repoguard initWhat happens in 2 seconds:
🔍 Auto-detects your tech stack (Next.js, NestJS, Express, FastAPI, Django, Gin, Fiber, Axum, Actix-web, Prisma, GORM, SQLx, Diesel, etc.).
🔐 Audits code and supported config files (
.env,.env.*,.json,.yaml,.toml,.pem,.key) for provider tokens and embedded database credentials.📝 Generates tailored
.cursorrules(for Cursor AI).🤖 Generates a comprehensive
CLAUDE.md(for Claude Code).🌊 Generates
.windsurfrules(for Windsurf IDE).🛡️ Generates
.github/copilot-instructions.md(for GitHub Copilot).⚙️ Configures pre-commit guard hooks & CI workflow.
🤖 Native Model Context Protocol (MCP) Server
RepoGuard ships with a built-in, zero-dependency MCP Server implementing the full 3-pillar standard (Tools, Resources, and Prompts) for Claude Desktop, Claude Code, Cursor, and Windsurf.
Connect to Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"repoguard": {
"command": "npx",
"args": ["-y", "repoguard-rules@1.7.0", "mcp"]
}
}
}Connect to Cursor (~/.cursor/mcp.json or .cursor/mcp.json):
{
"mcpServers": {
"repoguard": {
"command": "npx",
"args": ["-y", "repoguard-rules@1.7.0", "mcp"]
}
}
}MCP Capabilities:
🛠️ Tools:
repoguard_audit: Full repository audit against 16 architectural guardrails.repoguard_diff: Real-time audit of uncommitted git changes to catch AI drift before commit.repoguard_get_rules: Returns all 16 active architectural rules to prevent AI hallucination.repoguard_fix: Analyzes code snippets and returns actionable refactoring plans.
📦 Resources:
repoguard://rules: Direct JSON access to all architectural rules and remediation advice.repoguard://health: Real-time codebase health score and violation breakdown.
💡 Prompts:
architectural_review: Pre-configured prompt instructing AI agents to review diffs against Clean Architecture.clean_architecture_refactor: Pre-configured prompt to decouple controllers into Service and Repository layers.
🛠️ CLI Commands & Formats
Command | Description |
| Scans codebase and generates tailored AI context files (TS, Py, Go, Rust). |
| Evaluates entire codebase and returns an Architectural Health Score (A+ to F). |
| Generates standard OASIS SARIF v2.1.0 for GitHub Code Scanning integration. |
| Outputs machine-readable JSON for custom CI/CD pipelines. |
| Audits uncommitted git diffs against architectural rules in real-time. |
| Analyzes codebase and generates actionable before/after architectural refactoring suggestions. |
| Launches the Model Context Protocol stdio server for AI agents. |
| Configures local |
| Displays all 16 built-in architectural rules and descriptions. |
Ignoring Files & Folders (.repoguardignore)
Add a .repoguardignore file to your root directory to skip specific files or directories:
# .repoguardignore
legacy/
migrations/
test/fixtures/🛡️ Built-in Architectural Rules (16 Active Guardrails)
Rule ID | Category | Severity | Guardrail Enforced |
RULE-01 | Architecture | Error | Prohibits raw ORM/DB queries in UI components and Controllers (TS/JS). |
RULE-PY-01 | Architecture | Warning / Critical | Enforces FastAPI layer separation; forbids direct DB queries and raw commits ( |
RULE-GO-01 | Architecture | Warning / Critical | Enforces Clean Architecture in Go; prohibits raw database/GORM operations inside Gin, Fiber, or Echo HTTP handlers. |
RULE-GO-02 | Error Handling | Warning | Flags unchecked errors silenced via blank identifier ( |
RULE-RS-01 | Error Handling | Warning | Flags unsafe |
RULE-RS-02 | Architecture | Warning | Enforces Clean Architecture in Rust (Axum, Actix-web, Rocket); forbids direct SQLx / Diesel queries inside route handlers. |
RULE-02 | Security | Critical | Flags hardcoded secrets, private keys, and API tokens. |
RULE-SEC-01 | Security | Critical | Detects provider-format AI/cloud tokens and credential-bearing database URLs in source and supported config files. |
RULE-SEC-02 | Security | Critical | Flags unencrypted private cryptographic key headers ( |
RULE-09 | Security | Critical | Flags private secrets exposed via public prefixes ( |
RULE-03 | Type Safety | Warning | Forbids lazy |
RULE-04 | Code Quality | Info | Enforces structured logging instead of raw |
RULE-05 | Next.js / SSR | Error | Prevents hydration mismatch from browser globals ( |
RULE-06 | Security | Critical | Detects SQL injection hazards in raw query string interpolations. |
RULE-07 | API Design | Warning | Enforces schema validation (Zod/Pydantic) on incoming request payloads. |
RULE-08 | DRY Principle | Info | Prevents AI assistants from duplicating existing common utility helpers. |
🤖 GitHub Action & Security Integration
RepoGuard dogfoods its own architecture on every push. You can add continuous architectural enforcement to your CI/CD pipeline using the official Action:
# .github/workflows/ci.yml
name: CI & Architecture Guard
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
audit:
name: Unit Tests & Dogfood Audit
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Run Architecture & Stack Tests
run: npm test
- name: Dogfood Audit (RepoGuard on RepoGuard)
run: node bin/repoguard.js audit --strictGitHub Code Scanning (SARIF v2.1.0):
- run: npx repoguard-rules audit --format=sarif > repoguard.sarif
- uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: repoguard.sarif💎 Plans & Enterprise Upgrades
RepoGuard is 100% free and open-source for public repositories and local development. For automated CI/CD PR enforcement, private teams, and custom architectural rule engines:
Tier | Price | Ideal For | What's Included |
Open Source | $0 (Free Forever) | Solo builders & public repos | Unlimited local CLI scans, |
Developer Pro | $12 / month | Independent engineers & contractors | Unlimited private repositories, automated PR Review Bot, custom rules engine, secret leak detector |
Engineering Team | $39 / month | Startups & engineering orgs | Up to 5 devs, GitHub Org-wide CI/CD merge blocker, SOC2 architecture audit logs, Slack/Discord alerts |
👉 Subscribe to Developer Pro ($12/mo) • Upgrade Team ($39/mo) • 🇧🇷 Pagar no PIX (R$ 67 à vista)
📈 Star History
👥 Contributors & Community
Special thanks to the open source engineers contributing to RepoGuard:
@taylormatematica-beep (Lead Maintainer & Author)
@NihalPN — Authored
RULE-PY-01& FastAPI architectural guardrails (PR #3)
🌟 Support & Community
🌐 Documentation & Live Hub: https://taylormatematica-beep.github.io/repoguard/
📦 NPM Registry: https://www.npmjs.com/package/repoguard-rules
🐱 Product Hunt: https://www.producthunt.com/products/repoguard
If RepoGuard helps keep your AI coding clean, consider giving this repository a ⭐ Star!
Available Tools
4 toolsrepoguard_auditB
Audits a repository or directory against 16 Clean Architecture & Security guardrails (TypeScript, Python, Golang, Rust, Secrets 2.0) in ~12ms
| Name | Required | Description | Default |
|---|---|---|---|
| directory | No | Directory path to audit (defaults to current working directory) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden, and it does disclose useful behavioral traits: the fixed rule count, supported languages, and a ~12ms performance characteristic. However, it never states that the audit is read-only/side-effect free, whether it writes a report, or what permissions it needs.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single front-loaded sentence with zero waste; the core verb and scope lead, and the detail (languages, latency) trails.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple one-parameter tool this covers the essentials, but with no output schema and no annotations the description leaves the return shape unexplained (what an audit result looks like) and omits any read-only/destructive signal an agent needs to call it safely.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100% and the single optional 'directory' parameter is fully documented in the schema, including its default. The description adds no syntax or format detail beyond that, so the baseline of 3 applies.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a specific verb ('Audits') and resource ('repository or directory') and quantifies scope (16 Clean Architecture & Security guardrails across five languages). This clearly distinguishes it from repoguard_fix and repoguard_diff, though it never names those siblings explicitly.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No explicit when-to-use guidance or routing to alternatives. An agent could infer this is the detection step versus repoguard_fix, but nothing in the text states that relationship, exclusions, or prerequisites.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
repoguard_diffB
Audits uncommitted git changes in real-time to detect architectural drift before commit
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full behavioral burden. It says what is audited but omits whether the operation is read-only, what permissions are needed, how results are reported, and whether it modifies the working tree.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single front-loaded sentence with no wasted words. The purpose and timing appear immediately.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a no-parameter tool, the core purpose is stated. With no output schema and no annotations, the description leaves gaps about return values, error behavior, and execution context, making it minimally adequate rather than fully complete.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool takes zero parameters, so the baseline is 4. The description correctly adds no parameter information because none is needed.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a specific verb and resource: auditing uncommitted git changes for architectural drift. The 'before commit' timing adds scope, but it does not name or contrast itself with siblings like repoguard_audit, so the agent must infer the distinction.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Implies use before committing and on uncommitted changes, which gives some context. However, there is no explicit when-not-to-use guidance and no mention of repoguard_audit or other sibling alternatives.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
repoguard_fixC
Analyzes a code snippet and returns actionable clean architecture refactoring suggestions
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Source code content to inspect | |
| filename | Yes | Filename (e.g. src/controllers/user.controller.ts, src/routes/user.rs) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full behavioral burden. It implies a non-mutating read (returns suggestions rather than applying fixes), which is useful, but says nothing about whether any files are touched, permission/auth needs, or how many suggestions are returned.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single efficient sentence with no waste; the intent is front-loaded. It is perhaps slightly too terse for the tool's complexity, but nothing is padded.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
With only two simple parameters and no output schema, the description need not detail return values, but it also never characterizes the kinds of suggestions or scope of the analysis, leaving meaningful ambiguity for a tool whose name implies a stronger action than described.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100% with both required parameters fully documented (code content, filename with path examples), so the schema does the heavy lifting. The description adds no syntax or format detail beyond it, making the baseline 3 appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description gives a clear verb and resource ('analyzes a code snippet and returns... refactoring suggestions'), but the tool name 'repoguard_fix' suggests code modification while the description only promises suggestions, a mild tension. It does nothing to distinguish itself from sibling repoguard_audit, which plausibly also analyzes code, so an agent cannot confidently route between them.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
There is no when-to-use, when-not, or alternative guidance. With three siblings (audit, diff, get_rules) that could each plausibly apply to a snippet, the absence of routing guidance is a real gap.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
repoguard_get_rulesA
Returns all 16 active architectural rules to prevent AI hallucination of invalid layering patterns
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden. It does disclose two behavioral facts beyond the schema: the count is fixed at 16 and only 'active' rules are returned (implying inactive ones exist but are excluded). It says nothing about return shape, whether the rules are cached/versioned, or permission requirements.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single front-loaded sentence with no filler. The trailing rationale ('to prevent AI hallucination of invalid layering patterns') is arguably decorative, but it does convey why the ruleset exists.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a no-parameter, read-only lookup with no output schema, the description is close to sufficient — the agent knows it gets the full active ruleset. Missing only the delivery format of the rules and whether the set is stable across calls.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool takes zero parameters, so there is nothing for the description to disambiguate; the baseline for a 0-param tool applies. The description correctly implies no filtering arguments — everything is returned unconditionally.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a specific verb and resource ('Returns all 16 active architectural rules') with a scoping quantifier, so the agent knows exactly what comes back. It does not, however, distinguish itself from the sibling tools (audit, diff, fix), so the reader must infer the split from names alone.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The purpose clause implies usage — fetch the ruleset before validating layering — but there is no explicit statement of when to call this vs. repoguard_audit or repoguard_fix, and no prerequisites or ordering guidance. Minimum viable context only.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
4 tool updates
v1.7.0- First observed
repoguard_audit - First observed
repoguard_diff - First observed
repoguard_fix - First observed
repoguard_get_rules
TDQS
Scored across 4 tools
Each tool targets a distinct action: full-repo audit, uncommitted-diff audit, rule retrieval, and snippet-level fix suggestions. audit and diff share a domain but differ clearly in scope, and fix targets snippets rather than repos, so boundaries are mostly clear with minor potential overlap between audit and fix.
All four tools use the repoguard_ prefix followed by concise, lowercase verbs/nouns (audit, diff, get_rules, fix). The convention is consistent throughout with no style mixing.
Four tools is on the lean side but each one maps to a distinct need (audit, drift check, rules reference, fix suggestion) for a focused guardrail server. It is well-scoped, though slightly thin compared to a fuller lifecycle surface.
The surface covers auditing, incremental diff checks, rule introspection, and remediation suggestions, which are the core lifecycle for an architecture guardrail. Minor gaps exist (e.g., no rule configuration/customization or CI/report export), but agents can work around them.
Maintenance
Related MCP Connectors
Enforces architectural invariants and code quality rules inside your AI agent's edit loop.
Checks AI-written code against your rules as it is written, and keeps a record of what it found.
Lints + auto-fixes how AI coding agents discover any new product. 24 rules, 6 tools, score 0-100.
Deterministic runtime safety for AI agents: scan PII, gate tool actions, verify LLM output.
Related MCP Servers
- AlicenseNot gradedqualityAmaintenanceAI Constraint Engine that enforces CLAUDE.md, .cursorrules, and AGENTS.md rules as laws. 51 MCP tools for semantic conflict detection, patch review, drift scoring, pre-commit hooks, and Guardian Mode. Catches euphemisms, temporal evasion, and hidden violations that keyword matching misses.151 npm25MIT
- AlicenseAqualityDmaintenanceA deterministic architecture audit engine for Cursor. It enforces visual Mermaid protocols to prevent LLM hallucinations, ensuring AI modifies code based on strict blueprints.14 npmMIT
- AlicenseNot gradedqualityDmaintenanceFramework-agnostic architecture-rule enforcement for AI agents: analyzes Python codebases import graphs against declarative rulesets to report layer, forbidden-import, and cycle violations with file and line numbers. Supports MCP, OpenAI, Anthropic, LangChain, LlamaIndex, and CLI integrations.MIT
- AlicenseAqualityAmaintenanceMartinLoop is the independent governance and financial control layer for AI coding agents. Set hard spend limits, prevent runaway loops, enforce verification, trigger rollback on failure, and generate auditable receipts showing what changed, what it cost, and whether the work passed.24428 npm394Apache 2.0