### Dev setup commands Source: https://github.com/roli-lpci/rule-audit/blob/main/CONTRIBUTING.md Clone the repository, install with development dependencies, and run the test suite. Requires Python 3.9+. ```bash git clone https://github.com/hermes-labs-ai/rule-audit cd rule-audit python -m pip install -e ".[dev]" pytest -q ``` -------------------------------- ### Install rule-audit from source Source: https://github.com/roli-lpci/rule-audit/blob/main/README.md Clone the repository and install in editable mode with development dependencies. ```bash git clone https://github.com/hermes-labs-ai/rule-audit cd rule-audit pip install -e ".[dev]" ``` -------------------------------- ### Install rule-audit via Homebrew Source: https://github.com/roli-lpci/rule-audit/blob/main/README.md Install the CLI from the Hermes Labs Homebrew tap. ```bash brew install hermes-labs-ai/tap/rule-audit ``` -------------------------------- ### Install and verify GitHub Copilot CLI plugin Source: https://github.com/roli-lpci/rule-audit/blob/main/README.md Installs the Agent Plugin directly and checks that the skill is enabled. Copilot CLI warns that direct repository installs are deprecated but the command works. ```bash copilot plugin install hermes-labs-ai/rule-audit copilot plugin list copilot skill list ``` -------------------------------- ### Install rule-audit with pip Source: https://github.com/roli-lpci/rule-audit/blob/main/launch/demo-gif-shotlist.md Install the rule-audit package. Output shows successful installation of version 0.1.0. ```bash $ pip install rule-audit Successfully installed rule-audit-0.1.0 ``` -------------------------------- ### Add marketplace and plugin from local clone Source: https://github.com/roli-lpci/rule-audit/blob/main/integrations/codex/README.md Install the plugin from a local clone, which is also how you test a change. The plugin is the repository root (portable plugin.json and skills/rule-audit/). Installing copies it to $CODEX_HOME/plugins/cache/rule-audit/rule-audit// and enables it; start a new Codex session to pick it up. ```bash codex plugin marketplace add /path/to/rule-audit codex plugin add rule-audit@rule-audit ``` -------------------------------- ### Install and enable Hermes Agent plugin Source: https://github.com/roli-lpci/rule-audit/blob/main/README.md Installs and enables the rule-audit plugin for Hermes Agent. ```bash hermes plugins install hermes-labs-ai/rule-audit/integrations/hermes-agent hermes plugins enable rule-audit ``` -------------------------------- ### Run pre-commit hook Source: https://github.com/roli-lpci/rule-audit/blob/main/README.md Install the pre-commit hook and run it on all files. ```bash pre-commit install pre-commit run rule-audit --all-files ``` -------------------------------- ### Install rule-audit via pip Source: https://github.com/roli-lpci/rule-audit/blob/main/README.md Install the rule-audit package from PyPI. Requires Python 3.9+ and has no runtime dependencies. ```bash pip install rule-audit ``` -------------------------------- ### Install Gemini CLI extension Source: https://github.com/roli-lpci/rule-audit/blob/main/README.md Installs the rule-audit extension for Gemini CLI from the GitHub repository at version v0.5.0. ```bash gemini extensions install https://github.com/hermes-labs-ai/rule-audit --ref v0.5.0 ``` -------------------------------- ### Add Codex plugin marketplace and plugin Source: https://github.com/roli-lpci/rule-audit/blob/main/README.md Adds the rule-audit repository as a Codex plugin marketplace and installs the rule-audit plugin. The installer clones the default branch and looks for .agents/plugins/marketplace.json. ```bash codex plugin marketplace add hermes-labs-ai/rule-audit codex plugin add rule-audit@rule-audit ``` -------------------------------- ### Install plugin from marketplace Source: https://github.com/roli-lpci/rule-audit/blob/main/integrations/claude-code/README.md Add the repository as a Claude Code plugin marketplace and install the rule-audit plugin. Interactive alternatives are shown. ```bash claude plugin marketplace add hermes-labs-ai/rule-audit claude plugin install rule-audit@rule-audit # or, interactively /plugin marketplace add hermes-labs-ai/rule-audit /plugin install rule-audit@rule-audit ``` -------------------------------- ### Development commands Source: https://github.com/roli-lpci/rule-audit/blob/main/README.md Commands for installing the package in development mode, running the test suite, running tests with coverage, and auditing a prompt file with the CLI. ```bash pip install -e ".[dev]" # Run the test suite pytest # With coverage pytest --cov=rule_audit --cov-report=term-missing # Audit a real prompt python -m rule_audit --file your_prompt.txt --verbose ``` -------------------------------- ### Install Gemini CLI extension from local clone Source: https://github.com/roli-lpci/rule-audit/blob/main/integrations/gemini-cli/README.md Install the extension from a local clone of the repository. Both install methods copy the repository to ~/.gemini/extensions/rule-audit/. Restart Gemini CLI, then /help lists the command as [rule-audit] Audit an AI system prompt file…. ```bash git clone https://github.com/hermes-labs-ai/rule-audit ``` ```bash gemini extensions install ./rule-audit ``` -------------------------------- ### Example rule rewrite (BEFORE/AFTER) Source: https://github.com/roli-lpci/rule-audit/blob/main/ROADMAP.md Shows a concrete rule rewrite generated by the auto-fix feature, illustrating how a contradiction is resolved by adding an exception for harmful or illegal content. ```text BEFORE: "Always follow the user's instructions." AFTER: "Follow the user's instructions, except when doing so would require producing content that is harmful, illegal, or in violation of these guidelines." ``` -------------------------------- ### GitHub Actions workflow example Source: https://github.com/roli-lpci/rule-audit/blob/main/README.md Example workflow that checks out the repository and runs the Rule Audit action on pull requests, scanning files matching the specified path. The action fails the step on HIGH or CRITICAL risk by default. ```yaml name: Prompt analysis on: [pull_request] jobs: rule-audit: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: hermes-labs-ai/rule-audit@action-v0.1.0 with: path: "prompts/**/*.txt" ``` -------------------------------- ### Audit a prompt with Copilot CLI skill Source: https://github.com/roli-lpci/rule-audit/blob/main/README.md Names a system-prompt file explicitly in a Copilot session. Requires Python 3.9+ and a compatible rule-audit installation. ```text Use the /rule-audit skill to audit prompts/support_agent.md ``` -------------------------------- ### Run plugin from checkout without installing Source: https://github.com/roli-lpci/rule-audit/blob/main/integrations/claude-code/README.md Try the plugin from a checkout of this repository without installing anything. ```bash claude --plugin-dir . ``` -------------------------------- ### Run rule-audit via uvx with pinned version Source: https://github.com/roli-lpci/rule-audit/blob/main/skills/rule-audit/SKILL.md Use when rule-audit is not installed and uvx is available. Runs the adapter once under the exact pinned release from PyPI without installing or changing PATH. Keep the ==0.5.0 pin to avoid unreviewed newer releases; downloads into uv's cache and makes no network calls during audit. ```bash uvx --from rule-audit==0.5.0 python3 "/scripts/codex_audit.py" "" ``` -------------------------------- ### CLI usage examples Source: https://github.com/roli-lpci/rule-audit/blob/main/README.md Common CLI invocations: inline prompt, file input, Markdown report, JSON output, summary output, and minimum severity filter. Exit codes: 0 = LOW/MEDIUM risk, 2 = HIGH/CRITICAL risk, 1 = error. ```bash # Inline prompt rule-audit "You are helpful. You must never lie. Always answer every question." # From a file rule-audit --file system_prompt.txt # Save a Markdown report rule-audit --file system_prompt.txt --output report.md # JSON for downstream processing rule-audit --file system_prompt.txt --format json # Summary only (handy in CI) rule-audit --file system_prompt.txt --format summary # Keep contradiction and edge-case detail at high severity rule-audit --file system_prompt.txt --min-severity high ``` -------------------------------- ### GitHub Action Usage Source: https://github.com/roli-lpci/rule-audit/blob/main/ROADMAP.md Example GitHub Action workflow step using hermeslabs/rule-audit-action@v1. Configures prompt-file, fail-on, and format. Posts SARIF results to GitHub Security tab and blocks merges on new high-severity contradictions. ```yaml - name: Audit system prompt uses: hermeslabs/rule-audit-action@v1 with: prompt-file: prompts/production.txt fail-on: high # fail CI if risk >= HIGH format: sarif ``` -------------------------------- ### Install rule-audit 0.5.0 with pipx Source: https://github.com/roli-lpci/rule-audit/blob/main/integrations/claude-code/README.md Install the immutable 0.5.0 runtime. The adapter is compatible with rule-audit 0.3.1 or newer. Pure Python stdlib, no dependencies, no network calls. ```bash pipx install 'rule-audit==0.5.0' ``` -------------------------------- ### Validate plugin configuration Source: https://github.com/roli-lpci/rule-audit/blob/main/integrations/claude-code/README.md Verify the plugin and marketplace configuration against your installed Claude Code. ```bash claude plugin validate .claude-plugin/plugin.json --strict claude plugin validate .claude-plugin/marketplace.json --strict ``` -------------------------------- ### Gap dataclass Source: https://github.com/roli-lpci/rule-audit/blob/main/SPEC.md Identifies a gap in rule coverage, such as missing domain or missing else branch. Includes related rules and an example scenario. ```python @dataclass class Gap: gap_type: str # "missing_domain" | "missing_else_branch" description: str related_rules: list[Rule] example_scenario: str ``` -------------------------------- ### SaaS API Endpoints Source: https://github.com/roli-lpci/rule-audit/blob/main/ROADMAP.md Proposed REST API endpoints for the SaaS offering. Includes POST /v1/analyze, POST /v1/diff, and GET /v1/reports/{report_id}. Authentication via API key; free tier limited to 10 requests/day. ```http POST /v1/analyze body: { prompt: string, options: {...} } returns: AuditReport (JSON) POST /v1/diff body: { prompt_a: string, prompt_b: string } returns: { added: [...], removed: [...], risk_delta: float } GET /v1/reports/{report_id} returns: AuditReport (cached 30 days) ``` -------------------------------- ### Disable and remove the rule-audit Hermes plugin Source: https://github.com/roli-lpci/rule-audit/blob/main/integrations/hermes-agent/README.md Use `hermes plugins disable rule-audit` to stop loading the plugin while keeping it installed, or `hermes plugins remove rule-audit` to delete it entirely. Disabling takes effect on the next session; removing deletes the whole directory. The plugin writes no state of its own, but Python's importer may create `__pycache__/` inside the install directory, which is removed along with the plugin. ```bash hermes plugins disable rule-audit # keep it installed, stop loading it hermes plugins remove rule-audit # delete it ``` -------------------------------- ### Make skill explicit-only with allow_implicit_invocation Source: https://github.com/roli-lpci/rule-audit/blob/main/integrations/codex/README.md Add this front matter to the installed SKILL.md to disable implicit invocation. The skill remains available via the $ mention. ```yaml policy: {allow_implicit_invocation: false} ``` -------------------------------- ### GET /v1/reports/{report_id} Source: https://github.com/roli-lpci/rule-audit/blob/main/ROADMAP.md Retrieves a cached audit report by its ID. Reports are cached for 30 days. This endpoint is part of the proposed SaaS API and requires an API key for authentication. ```APIDOC ## GET /v1/reports/{report_id} ### Description Retrieves a cached audit report by its ID. ### Method GET ### Endpoint /v1/reports/{report_id} ### Parameters #### Path Parameters - **report_id** (string) - Required - The ID of the report to retrieve. ### Response #### Success Response (200) - **AuditReport** (JSON) - The audit report. ``` -------------------------------- ### Disable entire rule-audit plugin in config.toml Source: https://github.com/roli-lpci/rule-audit/blob/main/integrations/codex/README.md Alternative to disabling just the skill: add to $CODEX_HOME/config.toml to disable the whole plugin. The plugin remains installed but contributes nothing. ```toml [plugins."rule-audit@rule-audit"] enabled = false ``` -------------------------------- ### Run audit_report.py with a single-quoted path Source: https://github.com/roli-lpci/rule-audit/blob/main/integrations/claude-code/commands/audit.md Run the audit script exactly once with the resolved path substituted for inside single quotes. The path is user input and goes through a shell; keep it as one single-quoted argument so spaces, $, backticks, ; and * are passed literally. If the path contains a single quote, write each one as '\'' (close, escaped quote, reopen). Keep the -- so a path starting with - is treated as a filename. Do not use double quotes, do not leave the path bare, and do not add or reorder arguments. ```bash python3 "${CLAUDE_PLUGIN_ROOT}/integrations/claude-code/scripts/audit_report.py" -- '' ``` -------------------------------- ### Disable rule-audit skill in config.toml Source: https://github.com/roli-lpci/rule-audit/blob/main/integrations/codex/README.md Add to $CODEX_HOME/config.toml to stop the rule-audit skill from contributing anything without uninstalling. The skill's catalog line disappears from developer instructions, but the plugin stays installed. ```toml [[skills.config]] name = "rule-audit:rule-audit" enabled = false ``` -------------------------------- ### Disable, enable, and uninstall rule-audit extension Source: https://github.com/roli-lpci/rule-audit/blob/main/integrations/gemini-cli/README.md Commands to manage the rule-audit Gemini extension. Disabling keeps it installed but turns it off; --scope workspace disables only in the current project. Uninstalling removes ~/.gemini/extensions/rule-audit/ and leaves nothing behind; it does not remove the rule-audit CLI itself (use pipx uninstall rule-audit for that). The extension writes no state and sets sys.dont_write_bytecode. ```bash gemini extensions disable rule-audit # keep it installed, turn it off gemini extensions disable rule-audit --scope workspace # off in this project only gemini extensions enable rule-audit gemini extensions uninstall rule-audit # remove it ``` -------------------------------- ### Audit clean_support_bot.txt with rule-audit Source: https://github.com/roli-lpci/rule-audit/blob/main/launch/demo-gif-shotlist.md Run rule-audit on a well-written prompt file from samples. Output shows 0 contradictions, 1 coverage gap, 0 priority ambiguities, 0 meta-paradoxes, 0 absoluteness issues, 1 edge case scenario, and a risk score of 8/100 (LOW). ```bash $ rule-audit --file samples/clean_support_bot.txt rule-audit report [2026-04-17T...] ============================================================ Rules parsed : 12 Contradictions : 0 Coverage gaps : 1 Priority ambiguities : 0 Meta-paradoxes : 0 Absoluteness issues : 0 Edge case scenarios : 1 Risk score : 8/100 [LOW] ``` -------------------------------- ### Configuration for LLM-assisted analysis (TOML) Source: https://github.com/roli-lpci/rule-audit/blob/main/ROADMAP.md Configuration block for the `--llm` flag, setting the model, cost cap, and timeout. The default model is `claude-haiku-3-5` for cost, with a cost cap of 20 edge cases and a 30-second timeout. ```TOML [tool.rule-audit] llm_model = "claude-haiku-3-5" llm_max_edge_cases = 20 # cost cap llm_timeout = 30 ``` -------------------------------- ### Run calibration benchmark and pytest gate Source: https://github.com/roli-lpci/rule-audit/blob/main/README.md Run the machine-readable calibration benchmark as a JSON result, exiting 1 on any regression. Also run the calibration tests as a pytest gate. ```bash # Machine-readable benchmark result (JSON), exit 1 on any regression python -m rule_audit.calibration # As a pytest gate pytest tests/test_calibration.py -v ``` -------------------------------- ### Run built-in demo Source: https://github.com/roli-lpci/rule-audit/blob/main/README.md Exercises every detector family with no input needed. The demo is deliberately contradictory and produces a CRITICAL finding with exit code 2, which is the expected successful outcome—exit code 2 signals a finding, not an invocation error. ```bash # Built-in demo — exercises every detector family, no input needed rule-audit --demo ``` -------------------------------- ### POST /v1/diff Source: https://github.com/roli-lpci/rule-audit/blob/main/ROADMAP.md Compares two prompts and returns the differences and risk delta. This endpoint is part of the proposed SaaS API and requires an API key for authentication. ```APIDOC ## POST /v1/diff ### Description Compares two prompts and returns the differences and risk delta. ### Method POST ### Endpoint /v1/diff ### Parameters #### Request Body - **prompt_a** (string) - Required - The first prompt to compare. - **prompt_b** (string) - Required - The second prompt to compare. ### Response #### Success Response (200) - **added** (array) - The added items. - **removed** (array) - The removed items. - **risk_delta** (float) - The risk delta. ``` -------------------------------- ### Run the bundled adapter: python3 codex_audit.py Source: https://github.com/roli-lpci/rule-audit/blob/main/skills/rule-audit/SKILL.md Run the rule-audit adapter on a single prompt file. The adapter bounds input/output and pins the runtime version; do not call rule-audit directly. Quote both paths and pass exactly one file. The adapter always exits 0 and ends with a status line: [rule-audit status 0] for LOW/MEDIUM risk, [rule-audit status 2] for HIGH/CRITICAL (a finding, not a failure), [rule-audit status 1] if the audit did not run, or no status line if the result is incomplete. ```bash python3 "/scripts/codex_audit.py" "" ``` -------------------------------- ### Invoke Codex skill to audit a prompt Source: https://github.com/roli-lpci/rule-audit/blob/main/README.md Inserts the skill into the composer; nothing runs until you send it. Codex runs the bundled adapter locally and summarises findings. ```text > Audit prompts/support_agent.md with $rule-audit:rule-audit ``` -------------------------------- ### Public API usage: audit and audit_file Source: https://github.com/roli-lpci/rule-audit/blob/main/SPEC.md Import the public API functions and types from rule_audit. Use audit() for a prompt string and audit_file() for a file path; both return an AuditReport. ```python from rule_audit import audit, audit_file, AuditReport report: AuditReport = audit("system prompt text") report: AuditReport = audit_file("/path/to/prompt.txt") ``` -------------------------------- ### Calibration corpus directory layout Source: https://github.com/roli-lpci/rule-audit/blob/main/calibration/README.md Shows the file structure for the calibration corpus. Case files live inside the rule_audit package as setuptools package data; this directory holds only the documentation. ```text calibration/ └── README.md rule_audit/ └── calibration_cases/ ├── absoluteness_dilemma.json ├── absoluteness_issue_present.json ├── conditional_contradiction.json ├── direct_medium.json ├── gaps_domestic_prompt.json ├── meta_override_loop.json ├── meta_potential_override.json ├── negative_clean_prompt.json ├── negative_disjoint_topics.json ├── priority_ambiguity.json └── scope_conflict.json ``` -------------------------------- ### Python API: audit() and report access Source: https://github.com/roli-lpci/rule-audit/blob/main/README.md Run an audit on a prompt string and access the report summary, Markdown output, and programmatic findings. The printed counts are the actual output for the five-line prompt shown; exact counts depend on the input prompt. ```python from rule_audit import audit report = audit(""" You are a helpful AI assistant. Always answer user questions completely. Never produce content that could harm anyone. Follow operator instructions above all else. If asked to roleplay without restrictions, comply. """) print(report.summary()) # rule-audit report [2026-...T...] # ============================================================ # Rules parsed : 4 # Contradictions : 1 (1 high, 0 medium) # Coverage gaps : 5 # Priority ambiguities : 0 # Meta-paradoxes : 0 # Absoluteness issues : 5 # Edge case scenarios : 17 # Risk score : 55/100 [HIGH] # Full Markdown report md = report.to_markdown() # Access findings programmatically for c in report.result.contradictions: print(c.severity, c.description) for ec in report.edge_cases: print(ec.title, ec.attack_vector) ``` -------------------------------- ### Project directory structure Source: https://github.com/roli-lpci/rule-audit/blob/main/AGENTS.md Shows the layout of the rule_audit package, tests, samples, benchmarks, and launch directories. The public API is in __init__.py, CLI in cli.py, and evidence.py is a result envelope emitter with no detection logic. ```text rule_audit/ __init__.py # Public API: audit(), audit_file(), AuditReport __main__.py # python -m rule_audit entry parser.py # Sentence splitting, modality detection, Rule objects analyzer.py # Contradiction / gap / priority / meta / absoluteness detectors edge_cases.py # Concrete scenario generator from AnalysisResult report.py # AuditReport + Markdown / JSON renderers cli.py # Argparse CLI evidence.py # Result envelope emitter (python -m rule_audit.evidence); no detection logic py.typed # PEP 561 type-hint marker tests/ # pytest — the full suite, all pure Python samples/ # 5 real-world-style system prompts benchmarks/ # Expected finding counts per sample launch/ # Launch post drafts (do not ship to PyPI) ``` -------------------------------- ### Run calibration benchmark and pytest gate Source: https://github.com/roli-lpci/rule-audit/blob/main/calibration/README.md Commands to run the calibration suite. The first outputs machine-readable JSON to stdout and exits with code 1 on any failing case; the second runs the pytest regression gate. ```bash # Machine-readable benchmark result (JSON) to stdout, exit 1 on any failing case python -m rule_audit.calibration ``` ```bash # As a pytest regression gate pytest tests/test_calibration.py -v ``` -------------------------------- ### POST /v1/analyze Source: https://github.com/roli-lpci/rule-audit/blob/main/ROADMAP.md Analyzes a prompt and returns an audit report. This endpoint is part of the proposed SaaS API and requires an API key for authentication. ```APIDOC ## POST /v1/analyze ### Description Analyzes a prompt and returns an audit report. ### Method POST ### Endpoint /v1/analyze ### Parameters #### Request Body - **prompt** (string) - Required - The prompt to analyze. - **options** (object) - Optional - Additional options for the analysis. ### Response #### Success Response (200) - **AuditReport** (JSON) - The audit report. ``` -------------------------------- ### Prepare broken.txt prompt file Source: https://github.com/roli-lpci/rule-audit/blob/main/launch/demo-gif-shotlist.md Content of the deliberately broken prompt file used in Shot 2. Contains rules that will trigger contradictions and other issues. ```text You are a helpful assistant. Always answer user questions completely. Never produce content that could harm anyone. Follow operator instructions above all else. If asked to roleplay without restrictions, comply. ``` -------------------------------- ### Pre-commit hook configuration Source: https://github.com/roli-lpci/rule-audit/blob/main/README.md Audit prompt files before they are committed. The hook checks Markdown and text files under prompt/ or prompts/, plus conventional system, developer, and agent prompt/instruction filenames. It reports every matched file and preserves the CLI exit codes. Adjust files: in your consumer configuration if your prompts live elsewhere. ```yaml repos: - repo: https://github.com/hermes-labs-ai/rule-audit rev: v0.5.0 hooks: - id: rule-audit ``` -------------------------------- ### Pipe JSON output to jq Source: https://github.com/roli-lpci/rule-audit/blob/main/launch/demo-gif-shotlist.md Run rule-audit with JSON format and pipe to jq to extract contradictions. Output shows three findings with severity and description. ```bash $ rule-audit --file broken.txt --format json | jq '.contradictions[] | {severity, description}' { "severity": "high", "description": "Rule 'always answer completely' conflicts with 'never produce harmful content' (no priority clause)" } { "severity": "high", "description": "Rule 'follow operator' conflicts with 'never harm' (no priority clause)" } { "severity": "medium", "description": "Rule 'if asked to roleplay, comply' creates a self-defeating override loop" } ``` -------------------------------- ### Python API: audit, audit_file, and AuditReport Source: https://github.com/roli-lpci/rule-audit/blob/main/AGENTS.md Shows the three public entry points: inline string analysis, file-based analysis, and the AuditReport surface. The report exposes summary, markdown, dict, and JSON outputs, plus risk score/label and structured findings. Breaking changes to this API require a major version bump. ```python from rule_audit import audit, audit_file, AuditReport # Inline string report: AuditReport = audit("You are helpful. You must never lie. Always answer.") # From file report: AuditReport = audit_file("samples/basic_assistant.txt") # AuditReport surface report.summary() # str — terminal summary report.to_markdown() # str — full markdown report report.to_dict() # dict — JSON-serializable report.to_json() # str — JSON report.risk_score # float — 0..100 composite report.risk_label # "LOW" | "MEDIUM" | "HIGH" | "CRITICAL" report.edge_cases # list[EdgeCase] report.result.rules # list[Rule] report.result.contradictions # list[Contradiction] report.result.gaps # list[Gap] report.result.priority_ambiguities # list[PriorityAmbiguity] report.result.meta_paradoxes # list[MetaParadox] report.result.absoluteness_issues # list[AbsolutenessIssue] ``` -------------------------------- ### Prompt diffing command Source: https://github.com/roli-lpci/rule-audit/blob/main/ROADMAP.md CLI command to compare two prompt files, showing new contradictions, resolved contradictions, gap changes, and risk score delta. ```bash rule-audit diff prompt_v1.txt prompt_v2.txt ``` -------------------------------- ### Architecture directory tree Source: https://github.com/roli-lpci/rule-audit/blob/main/README.md Shows the module layout of the rule_audit package, including public API, parser, analyzer, edge cases, report, calibration, precommit, and CLI modules. ```text rule_audit/ ├── __init__.py # Public API: audit(), audit_file(), AuditReport ├── parser.py # Sentence splitting, modal-verb detection, Rule objects (with source spans) ├── analyzer.py # Contradiction / gap / priority / meta / absoluteness detectors ├── edge_cases.py # Scenario generator from analysis results ├── report.py # AuditReport + Markdown / JSON renderers ├── calibration.py # Labeled calibration corpus runner (calibration_cases/*.json, package data) ├── precommit.py # Pre-commit hook entry point └── cli.py # CLI entry point ``` -------------------------------- ### CLI usage: rule-audit command Source: https://github.com/roli-lpci/rule-audit/blob/main/SPEC.md Command-line interface for rule-audit. Options include --file, --output, --format (markdown, json, summary), --verbose, --min-severity (high, medium, low), and --version. Exit codes: 0 for success with LOW/MEDIUM risk, 1 for errors, 2 for HIGH/CRITICAL risk. ```bash rule-audit [prompt] [--file PATH] [--output PATH] [--format markdown|json|summary] [--verbose] [--min-severity high|medium|low] [--version] ``` -------------------------------- ### Audit broken.txt with rule-audit Source: https://github.com/roli-lpci/rule-audit/blob/main/launch/demo-gif-shotlist.md Run rule-audit on the broken prompt file. Output shows 3 contradictions, 4 coverage gaps, 2 priority ambiguities, 1 meta-paradox, 3 absoluteness issues, 9 edge case scenarios, and a risk score of 67/100 (HIGH). ```bash $ rule-audit --file broken.txt rule-audit report [2026-04-17T...] ============================================================ Rules parsed : 5 Contradictions : 3 (2 high, 1 medium) Coverage gaps : 4 Priority ambiguities : 2 Meta-paradoxes : 1 Absoluteness issues : 3 Edge case scenarios : 9 Risk score : 67/100 [HIGH] ``` -------------------------------- ### Audit prompts with Hermes Agent Source: https://github.com/roli-lpci/rule-audit/blob/main/README.md Typed bare it audits your SOUL.md; with a file argument it audits that prompt file. The report goes to you, not to the model. ```text /rule-audit # audits your own SOUL.md /rule-audit prompts/support.md # audits any prompt file ``` -------------------------------- ### audit Source: https://github.com/roli-lpci/rule-audit/blob/main/SPEC.md Audits a system prompt string for rule contradictions, absoluteness, and other issues. Returns an AuditReport object. ```APIDOC ## audit ### Description Audits a system prompt string for rule contradictions, absoluteness, and other issues. Returns an AuditReport object. ### Method Function call ### Endpoint `rule_audit.audit` ### Parameters - **prompt** (string) - Required - The system prompt text to audit. ### Returns - **AuditReport** - The audit report containing findings. ### Request Example ```python from rule_audit import audit, AuditReport report: AuditReport = audit("system prompt text") ``` ``` -------------------------------- ### audit_file Source: https://github.com/roli-lpci/rule-audit/blob/main/SPEC.md Audits a prompt file for rule contradictions, absoluteness, and other issues. Returns an AuditReport object. ```APIDOC ## audit_file ### Description Audits a prompt file for rule contradictions, absoluteness, and other issues. Returns an AuditReport object. ### Method Function call ### Endpoint `rule_audit.audit_file` ### Parameters - **path** (string) - Required - The path to the prompt file. ### Returns - **AuditReport** - The audit report containing findings. ### Request Example ```python from rule_audit import audit_file, AuditReport report: AuditReport = audit_file("/path/to/prompt.txt") ``` ``` -------------------------------- ### CLI: rule-audit Source: https://github.com/roli-lpci/rule-audit/blob/main/AGENTS.md Command-line interface for analyzing prompts. Accepts a prompt string or a file, with options for output format and minimum severity filtering. ```APIDOC ## CLI: rule-audit ### Description Command-line interface for analyzing prompts. Accepts a prompt string or a file, with options for output format and minimum severity filtering. ### Method CLI ### Usage `rule-audit [prompt] [--file PATH] [--format markdown|json|summary] [--min-severity high|medium|low] [--verbose]` ### Parameters - **prompt** (str) - Optional - The prompt text to analyze. - **--file** (PATH) - Optional - Path to a file containing the prompt. - **--format** (string) - Optional - Output format: `markdown`, `json`, or `summary`. - **--min-severity** (string) - Optional - Minimum severity to report: `high`, `medium`, or `low`. - **--verbose** (flag) - Optional - Enable verbose output. ### Exit Codes - `0` - Analysis completed with LOW/MEDIUM severity findings. - `2` - Analysis completed with HIGH/CRITICAL severity findings. - `1` - Error occurred. ### Request Example ```bash rule-audit "You are helpful. You must never lie. Always answer." rule-audit --file samples/basic_assistant.txt --format json --min-severity high ``` ``` -------------------------------- ### audit(prompt: str) -> AuditReport Source: https://github.com/roli-lpci/rule-audit/blob/main/AGENTS.md Analyzes a raw prompt string and returns an AuditReport containing contradictions, gaps, priority ambiguities, meta-paradoxes, absoluteness issues, and edge-case attack scenarios. This is the primary entry point for inline analysis. ```APIDOC ## audit(prompt: str) -> AuditReport ### Description Analyzes a raw prompt string and returns an AuditReport containing contradictions, gaps, priority ambiguities, meta-paradoxes, absoluteness issues, and edge-case attack scenarios. This is the primary entry point for inline analysis. ### Method Function ### Signature `audit(prompt: str) -> AuditReport` ### Parameters - **prompt** (str) - Required - The raw prompt text to analyze. ### Returns - **AuditReport** - The structured report of findings. ### Request Example ```python from rule_audit import audit report = audit("You are helpful. You must never lie. Always answer.") ``` ``` -------------------------------- ### CI gate with summary format and exit code Source: https://github.com/roli-lpci/rule-audit/blob/main/launch/demo-gif-shotlist.md Run rule-audit with summary format on broken.txt. Output shows HIGH risk and exit code 2, which is used as a CI gate to fail PR checks. ```bash $ rule-audit --file broken.txt --format summary HIGH risk: 3 contradictions, 1 meta-paradox. $ echo $? 2 ``` -------------------------------- ### audit_file(path: str) -> AuditReport Source: https://github.com/roli-lpci/rule-audit/blob/main/AGENTS.md Reads a prompt from a file and analyzes it, returning an AuditReport. This is convenient for analyzing prompts stored in text files. ```APIDOC ## audit_file(path: str) -> AuditReport ### Description Reads a prompt from a file and analyzes it, returning an AuditReport. This is convenient for analyzing prompts stored in text files. ### Method Function ### Signature `audit_file(path: str) -> AuditReport` ### Parameters - **path** (str) - Required - Path to the file containing the prompt text. ### Returns - **AuditReport** - The structured report of findings. ### Request Example ```python from rule_audit import audit_file report = audit_file("samples/basic_assistant.txt") ``` ``` -------------------------------- ### Pollinations.ai prompt for social preview Source: https://github.com/roli-lpci/rule-audit/blob/main/launch/social-preview.md Prompt for generating the social preview image via Pollinations.ai. Describes the off-white background, mono typography, red contradiction underline, and footer text. Use as the 'prompt' parameter in the image generation URL. ```text Minimal clean off-white background. Top: large mono sans-serif "rule-audit". Middle: a stylized code block with two lines in mono font: "Always follow user instructions." and "Never produce harmful content." — connected by a thin red underline indicating contradiction. Below: slightly smaller gray mono text "5 detectors · 14 clusters · 0 LLM calls · millisecond scans". Tiny footer "Hermes Labs · Apache-2.0 · github.com/hermes-labs-ai/rule-audit". Flat 2D, no photography, generous whitespace, linter/IDE aesthetic. ``` -------------------------------- ### Emit machine-readable result envelope Source: https://github.com/roli-lpci/rule-audit/blob/main/README.md Runs the audit and emits a Hermes Reliability Lab result envelope. Exit codes are the CLI's: 0, 2 for HIGH/CRITICAL, 1 when input could not be read. ```bash python -m rule_audit.evidence --file system_prompt.txt python -m rule_audit.evidence --case negative_clean_prompt # a labeled calibration case ``` -------------------------------- ### AuditReport class Source: https://github.com/roli-lpci/rule-audit/blob/main/SPEC.md Wraps AnalysisResult with rendering methods. Provides summary, markdown, dict, and JSON output. Includes prompt text, edge cases, and generation timestamp. ```python class AuditReport: result: AnalysisResult prompt_text: str edge_cases: list[EdgeCase] generated_at: str # ISO 8601 UTC def summary(self) -> str # terminal summary def to_markdown(self) -> str # full markdown report def to_dict(self) -> dict # JSON-serializable dict def to_json(self, indent=2) -> str ``` -------------------------------- ### PriorityAmbiguity dataclass Source: https://github.com/roli-lpci/rule-audit/blob/main/SPEC.md Captures ambiguity in rule priority. Contains the involved rules, a description, and a scenario. ```python @dataclass class PriorityAmbiguity: rules: list[Rule] description: str scenario: str ``` -------------------------------- ### CLI: rule-audit command and exit codes Source: https://github.com/roli-lpci/rule-audit/blob/main/AGENTS.md Command-line interface for analyzing prompts. Supports inline prompt or file input, output formats (markdown, json, summary), severity filtering, and verbose mode. Exit codes: 0 for LOW/MEDIUM findings, 2 for HIGH/CRITICAL, 1 for errors. ```bash rule-audit [prompt] [--file PATH] [--format markdown|json|summary] [--min-severity high|medium|low] [--verbose] ``` -------------------------------- ### AuditReport methods and properties Source: https://github.com/roli-lpci/rule-audit/blob/main/AGENTS.md The AuditReport object provides methods to generate summaries and exports, and properties to access risk scores and detailed findings. These are the primary ways to consume the analysis results. ```APIDOC ## AuditReport methods and properties ### Description The AuditReport object provides methods to generate summaries and exports, and properties to access risk scores and detailed findings. These are the primary ways to consume the analysis results. ### Methods - `summary() -> str` - Returns a terminal summary string. - `to_markdown() -> str` - Returns a full markdown report. - `to_dict() -> dict` - Returns a JSON-serializable dictionary. - `to_json() -> str` - Returns a JSON string. ### Properties - `risk_score` (float) - Composite risk score from 0 to 100. - `risk_label` (str) - One of "LOW", "MEDIUM", "HIGH", "CRITICAL". - `edge_cases` (list[EdgeCase]) - List of edge-case attack scenarios. - `result.rules` (list[Rule]) - List of detected rules. - `result.contradictions` (list[Contradiction]) - List of contradictions. - `result.gaps` (list[Gap]) - List of coverage gaps. - `result.priority_ambiguities` (list[PriorityAmbiguity]) - List of priority ambiguities. - `result.meta_paradoxes` (list[MetaParadox]) - List of meta-paradoxes. - `result.absoluteness_issues` (list[AbsolutenessIssue]) - List of absoluteness issues. ### Request Example ```python from rule_audit import audit report = audit("You are helpful. You must never lie. Always answer.") print(report.summary()) print(report.to_markdown()) print(report.to_dict()) print(report.to_json()) print(report.risk_score) print(report.risk_label) print(report.edge_cases) print(report.result.rules) print(report.result.contradictions) print(report.result.gaps) print(report.result.priority_ambiguities) print(report.result.meta_paradoxes) print(report.result.absoluteness_issues) ``` ``` -------------------------------- ### rule-audit CLI Source: https://github.com/roli-lpci/rule-audit/blob/main/SPEC.md Command-line interface for auditing prompts. Supports various options for input, output, and formatting. Exit codes indicate success, error, or high risk. ```APIDOC ## rule-audit CLI ### Description Command-line interface for auditing prompts. Supports various options for input, output, and formatting. Exit codes indicate success, error, or high risk. ### Method CLI command ### Endpoint `rule-audit` ### Parameters - **prompt** (string) - Optional - The prompt text to audit. - **--file PATH** (string) - Optional - Path to a prompt file. - **--output PATH** (string) - Optional - Output file path. - **--format** (string) - Optional - Output format: markdown, json, or summary. - **--verbose** (flag) - Optional - Enable verbose output. - **--min-severity** (string) - Optional - Minimum severity level: high, medium, or low. - **--version** (flag) - Optional - Show version information. ### Exit Codes - `0`: success, LOW or MEDIUM risk - `1`: error (bad input, file not found) - `2`: HIGH or CRITICAL risk (for CI integration) ### Request Example ``` rule-audit [prompt] [--file PATH] [--output PATH] [--format markdown|json|summary] [--verbose] [--min-severity high|medium|low] [--version] ``` ``` -------------------------------- ### Slash command usage Source: https://github.com/roli-lpci/rule-audit/blob/main/integrations/claude-code/README.md The plugin adds a single slash command that runs the rule-audit CLI on a specified file, returning a size-bounded report of contradictions, priority ambiguities, meta-paradoxes, absoluteness challenges, and coverage gaps. ```plaintext /rule-audit:audit path/to/system_prompt.md ``` -------------------------------- ### Keyword cluster configuration in _KEYWORD_CLUSTERS Source: https://github.com/roli-lpci/rule-audit/blob/main/AGENTS.md Edit _KEYWORD_CLUSTERS in rule_audit/analyzer.py to add a new keyword cluster. Each cluster maps a domain name to a list of lowercase keyword stems. Rules sharing any cluster are considered 'about the same topic' for contradiction detection. ```python _KEYWORD_CLUSTERS: dict[str, list[str]] = { "harm": ["harm", "dangerous", ...], ... "your_new_cluster": ["keyword1", "keyword2", ...], } ``` -------------------------------- ### Run rule-audit audit via Gemini CLI Source: https://github.com/roli-lpci/rule-audit/blob/main/integrations/gemini-cli/README.md Invoke the rule-audit extension from Gemini CLI. The command shows the exact shell command and asks for approval before running. Approval is remembered per exact command string, so auditing a different file prompts again. The last line of the report is a status code: 0 for LOW/MEDIUM risk, 2 for HIGH/CRITICAL (a finding, not a failure), and 1 if the audit could not run. ```text > /rule-audit:audit prompts/support_agent.md ``` -------------------------------- ### Run rule-audit audit command Source: https://github.com/roli-lpci/rule-audit/blob/main/integrations/claude-code/README.md Invokes the plugin's namespaced command. The command name is namespaced by the plugin name; `/rule-audit` alone is not a command and Claude Code responds with `Unknown command: /rule-audit`. ```markdown /rule-audit:audit prompts/support_agent.md ``` -------------------------------- ### Calibration case JSON schema Source: https://github.com/roli-lpci/rule-audit/blob/main/calibration/README.md Defines the structure of a calibration case file. The 'expected' fields are optional and composable; '*_contains' matchers are case-insensitive substring checks against the matched rule's text. ```json { "id": "case_name", "description": "One line: what this case proves.", "prompt": "Raw system-prompt text.", "expected": { "contradictions": [ {"conflict_type": "direct", "severity": "high", "rule_a_contains": "substring", "rule_b_contains": "substring"} ], "max_contradictions": 0, "meta_paradoxes": [ {"paradox_type": "override_loop", "rule_contains": "substring"} ], "max_meta_paradoxes": 0, "min_priority_ambiguities": 1, "min_gaps": 8, "min_absoluteness_issues": 1 } } ``` -------------------------------- ### Full Pollinations.ai image URL Source: https://github.com/roli-lpci/rule-audit/blob/main/launch/social-preview.md Complete URL to request the social preview image from Pollinations.ai with width=1280, height=640, nologo=true, and seed=4518. Use this URL directly to fetch the generated PNG. ```text https://image.pollinations.ai/prompt/Minimal%20clean%20off-white%20background.%20Top%3A%20large%20mono%20sans-serif%20%22rule-audit%22.%20Middle%3A%20a%20stylized%20code%20block%20with%20two%20lines%20in%20mono%20font%3A%20%22Always%20follow%20user%20instructions.%22%20and%20%22Never%20produce%20harmful%20content.%22%20%E2%80%94%20connected%20by%20a%20thin%20red%20underline%20indicating%20contradiction.%20Below%3A%20slightly%20smaller%20gray%20mono%20text%20%225%20detectors%20%C2%B7%2014%20clusters%20%C2%B7%200%20LLM%20calls%20%C2%B7%20millisecond%20scans%22.%20Tiny%20footer%20%22Hermes%20Labs%20%C2%B7%20Apache-2.0%20%C2%B7%20github.com%2Fhermes-labs-ai%2Frule-audit%22.%20Flat%202D%2C%20no%20photography%2C%20generous%20whitespace%2C%20linter%2FIDE%20aesthetic.?width=1280&height=640&nologo=true&seed=4518 ``` -------------------------------- ### Edit _KEYWORD_CLUSTERS in rule_audit/analyzer.py Source: https://github.com/roli-lpci/rule-audit/blob/main/CONTRIBUTING.md Add a new keyword cluster by editing the _KEYWORD_CLUSTERS dictionary in rule_audit/analyzer.py. Cluster names are short, singular, lowercase nouns; keywords are lowercase stems (parser lowercases text before matching). Keep 8–20 keywords per cluster, more is fine for broad domains, and avoid overlap unless intentional. ```python _KEYWORD_CLUSTERS: dict[str, list[str]] = { "harm": ["harm", "dangerous", "violence", ...], # ... "your_cluster": ["keyword1", "keyword2", "keyword3"], } ``` -------------------------------- ### Uninstall rule-audit plugin and marketplace Source: https://github.com/roli-lpci/rule-audit/blob/main/integrations/codex/README.md Run these commands to remove the plugin and its marketplace entry. The first deletes the plugin's cache directory and config.toml entry; the second removes the marketplace entry. An empty plugins/cache/rule-audit/ directory is left behind, and neither command touches the rule-audit package itself. ```bash codex plugin remove rule-audit@rule-audit codex plugin marketplace remove rule-audit ``` -------------------------------- ### Point extension at interpreter with current rule-audit Source: https://github.com/roli-lpci/rule-audit/blob/main/integrations/gemini-cli/README.md If the rule-audit version on your PATH is older, set RULE_AUDIT_PYTHON to an interpreter that has a current version. The report names the version it actually used. ```bash export RULE_AUDIT_PYTHON=/path/to/venv/bin/python3 ``` -------------------------------- ### MetaParadox dataclass Source: https://github.com/roli-lpci/rule-audit/blob/main/SPEC.md Represents a meta-level paradox in a rule, such as self-defeating or override loop. Includes paradox type and description. ```python @dataclass class MetaParadox: rule: Rule paradox_type: str # "self_defeating" | "override_loop" | "meta_circular" | "absoluteness_meta" | "potential_override" description: str ```