GuardianProtect your project architecture from AI agents and accidental restructuring. Guardian is a VS Code extension that acts as a protective middleware between coding agents (GitHub Copilot, Cursor, Cline, Aider, etc.) and your file system. It enforces a user-defined architecture configuration so that AI agents cannot arbitrarily restructure, move, delete, or create files/folders in ways that violate the project's intended architecture. Features
Getting Started
Configuration (
|
| Mode | Behavior |
|---|---|
block |
Reverts the change automatically and shows a notification |
warn |
Shows a warning notification with an "Undo" button |
ask |
Shows a modal dialog asking the user to approve or reject |
log |
Silently logs the violation to the output channel |
Commands
| Command | Description |
|---|---|
Guardian: Initialize Configuration |
Generates a starter .guardian.json |
Guardian: Enable/Disable |
Toggle the guardian on/off |
Guardian: Show Status |
Display current status and recent violations |
Guardian: Scan for Violations |
Check the entire workspace against rules |
Guardian: Take Structure Snapshot |
Save the current folder structure as a baseline |
Guardian: Open Configuration Wizard |
Interactive config editor |
MCP Server
Guardian includes a built-in Model Context Protocol (MCP) server that lets AI agents query and respect your architecture rules programmatically. This means agents like Claude Code, Cursor, and other MCP-compatible clients can check whether a file operation is allowed before making changes.
Available Tools
The MCP server exposes three tools:
| Tool | Description |
|---|---|
get_project_structure |
Returns the full set of architecture protection rules configured in .guardian.json (protected paths, locked files, folder structure, naming conventions, boundary rules). |
check_path |
Checks whether a specific file operation (edit, delete, rename, create) is allowed by the architecture rules. Use this before making changes. |
get_boundary_rules |
Returns import boundary rules and optionally scans the codebase for current violations. |
Available Resources
| Resource URI | Description |
|---|---|
guardian://config |
The raw .guardian.json configuration file for the project. |
Setup
VS Code / Cursor (automatic)
When Guardian is installed as a VS Code extension, the MCP server is automatically registered — no manual configuration needed. MCP-compatible agents running inside VS Code (such as GitHub Copilot agent mode or Cursor) can discover and use it out of the box.
Claude Code
Add the following to your project's .mcp.json file (create it in the project root if it doesn't exist):
{
"mcpServers": {
"architecture-guardian": {
"type": "stdio",
"command": "node",
"args": ["<path-to-extension>/bin/guardian-mcp.js"]
}
}
}
To find <path-to-extension>, locate where VS Code installed the Guardian extension:
- macOS:
~/.vscode/extensions/sceletonlabs.guardian-<version>/ - Linux:
~/.vscode/extensions/sceletonlabs.guardian-<version>/ - Windows:
%USERPROFILE%\.vscode\extensions\sceletonlabs.guardian-<version>\
For example on macOS:
{
"mcpServers": {
"architecture-guardian": {
"type": "stdio",
"command": "node",
"args": ["~/.vscode/extensions/sceletonlabs.guardian-0.1.0/bin/guardian-mcp.js"]
}
}
}
Tip: If you clone the Guardian repo locally, you can also point directly to that clone instead of the extension install path.
Other MCP Clients
The server uses stdio transport. Any MCP-compatible client can launch it by running:
node /path/to/guardian/bin/guardian-mcp.js
The server reads .guardian.json from the workspacePath argument provided in each tool call, or falls back to the current working directory.
Tool Examples
Check if deleting a file is allowed:
{
"tool": "check_path",
"arguments": {
"workspacePath": "/path/to/project",
"path": "src/core/auth.ts",
"action": "delete"
}
}
Get all architecture rules:
{
"tool": "get_project_structure",
"arguments": {
"workspacePath": "/path/to/project"
}
}
Scan for boundary violations:
{
"tool": "get_boundary_rules",
"arguments": {
"workspacePath": "/path/to/project",
"scan": true
}
}
How It Works
Guardian uses VS Code's workspace file system events (onDidCreateFiles, onDidDeleteFiles, onDidRenameFiles) to intercept changes in real-time. When a file operation matches a rule violation, the configured enforcement action is taken.
For boundary rules, the extension also watches for file saves and analyzes import statements to detect cross-boundary dependencies.
Compatibility
Works in VS Code, VS Code Insiders, and Cursor.
License
MIT