"Code -> audit -> amend -> audit again -> pass." Blind Auditor is a mandatory code auditing system built on the MCP (Model Context Protocol). It uses a unique "Thinking Isolation" mechanism to force AI Agents to enter an independent "audit phase" and self-review their code before outputting the final result. Traditional AI coding is often "generate and output," which allows errors and biases to sl
Add this skill
npx mdskills install Sim-xia/blind-auditorInnovative self-auditing MCP server that forces AI agents to review code against configurable rules before output
1# ๐ก๏ธ Blind Auditor - MCP Server23"Code -> audit -> amend -> audit again -> pass."45Blind Auditor is a **mandatory code auditing system** built on the MCP (Model Context Protocol). It uses a unique **"Thinking Isolation"** mechanism to force AI Agents to enter an independent "audit phase" and self-review their code before outputting the final result.67## ๐ง Core Philosophy: Thinking Isolation89Traditional AI coding is often "generate and output," which allows errors and biases to slip through. Blind Auditor introduces a middle layer:10111. **Intercept**: When the Agent wants to output code, it must first submit it to Blind Auditor.122. **Isolate**: Blind Auditor does not return the result immediately. Instead, it injects a **mandatory system instruction**, forcing the Agent to pause its current persona and switch to a "Ruthless Auditor" role.133. **Audit**: In this isolated context, the Agent must scan the generated code line by line against the predefined `rules.json`.144. **Release**: The code is unlocked and returned to the user only when the audit score meets the threshold (default > 80) and there are no Critical issues.1516## ๐ฏ Key Features1718- **๐ก๏ธ Zero Trust Architecture**: Default distrust of the Agent's initial draft; it must pass an audit.19- **๐ฐ Zero Extra Cost**: Reuses the host IDE's current session model, requiring no additional API Key.20- **โ๏ธ Bias Removal**: Forces a perspective switch via Prompt injection to break generation inertia.21- **๐ Strict Compliance**: Hard-codes team code standards (`rules.json`) into the generation process, which is more effective than simple Prompts.22- **๐ Auto-Fix Loop**: Automatically triggers a "fix-resubmit" loop upon audit failure until compliance is met or the maximum retry count is reached.2324---2526## ๐ Quick Start2728### 1. Prerequisites2930This project requires Python 3.10+ and [uv](https://docs.astral.sh/uv/).3132```bash33# Install uv (if not already installed)34curl -LsSf https://astral.sh/uv/install.sh | sh3536# Enter project directory37cd blind-auditor3839# Install dependencies (automatically creates virtual environment)40uv sync41```4243### 2. Configure Audit Rules (`rules.json`)4445Create or edit `rules.json` in the project root. This is the auditor's "Rulebook".4647```json48{49 "project_name": "MyCoreProject",50 "strict_mode": true,51 "max_retries": 3,52 "rules": [53 {54 "id": "SEC-001",55 "severity": "CRITICAL",56 "description": "Strictly prohibit hardcoding any API Keys, passwords, or sensitive Tokens.",57 "weight": 5058 },59 {60 "id": "PERF-001",61 "severity": "WARNING",62 "description": "Avoid database queries or IO operations inside loops.",63 "weight": 1564 },65 {66 "id": "STYLE-001",67 "severity": "PREFERENCE",68 "description": "Use snake_case for variable names.",69 "weight": 570 }71 ]72}73```7475**Configuration Fields**:76- `severity`:77 - `CRITICAL`: Fatal error. If found, the audit fails immediately. Usually carries a high penalty.78 - `WARNING`: Warning. Moderate penalty; accumulation can lead to failure.79 - `PREFERENCE`: Style preference. Low penalty.80- `weight`: The penalty points deducted when this rule is violated (Total score: 100).8182### 3. Configure IDE (Antigravity / Cursor / Windsurf)8384#### Step A: Add System Prompt (Critical)8586To ensure the Agent knows it must use this tool, add the following instruction to your `.cursorrules` or IDE System Prompt settings:8788```markdown89# Blind Auditor Protocol90**CRITICAL INSTRUCTION**:91You are integrated with the **Blind Auditor MCP**.92Whenever you generate code for a user request, you **MUST NOT** output the code block directly to the user.9394**Execution Protocol**:951. **Draft**: Generate the code internally in your thought process.962. **Submit**: Call the `submit_draft` tool with your code and language.973. **Obey**: The tool will return a strict "Audit Instruction". You MUST follow it exactly to audit your own code.984. **Finalize**: Only when the tool returns "โ AUDIT PASSED" can you display the final code to the user.99100**Prohibited**:101- Do NOT output code blocks before passing the audit.102- Do NOT skip the audit step for "simple" changes.103```104105#### Step B: Configure MCP Server106107Add the following to your MCP client configuration file (e.g., `claude_desktop_config.json` or IDE settings):108109**Note**: Replace `/path/to/your/blind-auditor` with the actual absolute path where you cloned this repository.110111```json112{113 "mcpServers": {114 "blind-auditor": {115 "command": "uv",116 "args": ["run", "--directory", "/path/to/your/blind-auditor", "blind-auditor"]117 }118 }119}120```121122---123124## ๐ง Tool Details125126### 1. `submit_draft`127Submit a code draft.128- **Input**: `code` (content), `language` (programming language)129- **Behavior**: Locks the session and returns mandatory audit instructions.130131### 2. `submit_audit_result`132Submit your audit conclusion.133- **Input**:134 - `passed` (bool): Whether you believe it passed.135 - `issues` (list): List of issues found.136 - `score` (int): Score from 0-100.137- **Behavior**:138 - If `score < 80`, forces `passed=False`.139 - If passed, unlocks the code.140 - If failed, increments retry count and requires the Agent to fix and resubmit.141142### 3. `reset_session`143Resets the state and clears the retry count.144145---146147## ๐ Workflow Diagram148149```mermaid150graph TD151 User["User Request"] --> Agent152 Agent["Agent Generates Draft"] -->|1. submit_draft| MCP153 MCP -->|2. Inject Audit Instructions| Agent154155 subgraph Isolation ["Thinking Isolation"]156 Agent -->|3. Self-Review| Agent157 Agent -->|4. submit_audit_result| MCP158 end159160 MCP -->|5. Verdict| Decision{"Passed?"}161162 Decision -->|No - Issues Found| Retry["Retry Count +1"]163 Retry -->|Limit Not Reached| Fix["Agent Fixes Code"]164 Fix -->|Resubmit| Agent165166 Decision -->|Yes - Score >= 80| Final["โ Output Final Code"]167168 Retry -->|Limit Reached| Force["โ ๏ธ Force Output - With Warning"]169```170171## โ Troubleshooting172173**Q: The Agent always outputs code directly without calling tools.**174A: Check if the System Prompt is configured correctly. You must explicitly tell the Agent "Do NOT output code directly". You can also manually remind it in the chat: "Please audit via Blind Auditor first".175176**Q: Why does it fail even if I give the code 100 points?**177A: Check if any `CRITICAL` rules in `rules.json` were triggered. Current logic mainly relies on the `score` passed by the Agent, but if `passed` is `True` while `score < 80`, the system will force a rejection.178179**Q: Which programming languages are supported?**180A: Theoretically, all languages are supported. Blind Auditor itself does not parse code syntax but relies on the Agent's understanding to match descriptions in `rules.json`.181182---183184## ๐ ๏ธ Development Guide185186```bash187# Run server188uv run blind-auditor189190# Or run directly with Python module191uv run python -m src.main192193# Debug mode (output to stderr)194# View print statements in src/main.py195```196197## ๐ License198199MIT License200
Full transparency โ inspect the skill content before installing.