agentleFS
roli-lpciroli-lpci/rule-audit/.claude/CLAUDE.md

rule-audit

CLAUDE.md3 starsChanged 3 months agoApache-2.0View on GitHub

  • Installs packages

The file

We split this CLAUDE.md into the rules it gives an agent

8 rules. About 0 are common, 2 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    No LLM dependency: All analysis is regex + heuristics.

    line 31
  2. Very specific:

    Add detection function in analyzer.py returning a list of result objects

    line 38
  3. Very specific:

    Add result dataclass in analyzer.py

    line 39
  4. Very specific:

    Call it in analyze() and include in AnalysisResult

    line 40
  5. Very specific:

    Add edge case generator in edge_cases.py → generate_edge_cases()

    line 41
  6. Very specific:

    Add renderer in report.py

    line 42
  7. Very specific:

    Add tests in tests/test_analyzer.py

    line 43
  8. Distinctive:

    No support for multi-document prompts (operator + user + tool results)

    line 53

≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

CLAUDE.md — rule-audit

What This Is

Static analyzer for AI system prompts. Finds contradictions, gaps, and exploitable edge cases. Pure Python, no LLM dependency. Built at Hermes Labs Hackathon Round 8.

Project Structure

rule_audit/
├── __init__.py      # audit(), audit_file(), AuditReport exports
├── parser.py        # Rule extraction from raw text
├── analyzer.py      # Core analysis: contradictions, gaps, priority, meta, absoluteness
├── edge_cases.py    # EdgeCase generation from AnalysisResult
├── report.py        # AuditReport class + Markdown renderer
└── cli.py           # CLI entry point (python -m rule_audit)

tests/
├── test_parser.py   # Parser unit tests
└── test_analyzer.py # Analyzer unit tests (includes hackathon prompt integration test)

Run Tests

cd /path/to/rule-audit
pip install -e ".[dev]"
pytest
pytest --cov=rule_audit --cov-report=term-missing

Key Design Decisions

  • No LLM dependency: All analysis is regex + heuristics. Fast, deterministic, offline.
  • Rule objects are immutable dataclasses: Parser produces them, analyzer consumes them, nothing mutates.
  • Severity is propagated: Contradictions have severity; EdgeCases inherit or derive severity. AuditReport.risk_score is a weighted sum.
  • Keyword clusters: 14 semantic clusters in analyzer.py → _KEYWORD_CLUSTERS. Add new clusters there to expand detection coverage.
  • Modality opposition table: _CONTRADICTORY_PAIRS in analyzer.py defines which modality pairs are contradictory. Extend this set to add new contradiction logic.

Adding New Detectors

  1. Add detection function in analyzer.py returning a list of result objects
  2. Add result dataclass in analyzer.py
  3. Call it in analyze() and include in AnalysisResult
  4. Add edge case generator in edge_cases.py → generate_edge_cases()
  5. Add renderer in report.py
  6. Add tests in tests/test_analyzer.py

Adding New Keyword Clusters

Edit _KEYWORD_CLUSTERS in analyzer.py. Each cluster is a list of keywords. Cluster membership is used to determine if two rules are "about the same topic".

Known Limitations

  • Parser is heuristic — it will miss some rules and may over-parse others
  • Absoluteness scoring is lexical only — semantic absoluteness isn't captured
  • Contradiction detection is O(n²) in rules — fine for real prompts (n < 100)
  • No support for multi-document prompts (operator + user + tool results)

Backlog (out of scope: start only when asked)

  • Rule diffing between prompt versions
  • LLM-augmented semantic contradiction detection (optional plugin)
  • GitHub Action for CI integration
  • Web UI with prompt editor
  • Export to CSV / SARIF format for compliance toolchains

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.