Automatically discover and document coding conventions in your codebase
Project description
klaussy-repo-conventions 🔍
Discover once, align everywhere. The core conventions discovery and repository mapping engine. It scans codebases for structural styles, rates conventions on a 1-5 scale, traces endpoint-to-store data flows, and compiles a canonical
CLAUDE.mdand rules folder consumed byklaussy-agents.
Designed by an ex-GitHub, ex-Twitch, and ex-Microsoft engineer, klaussy-repo-conventions is a lightweight, AST-backed static-analysis CLI. It parses file patterns, naming conventions, import trees, and error handling behaviors across multiple programming languages—acting as the single source of truth for downstream AI agent configuration.
⚡ Quick Start
Analyze your codebase and generate agent-optimized context files in seconds:
# Install using pipx (recommended)
pipx install klaussy-repo-conventions
# Scan the current directory
conventions discover
This scans the local workspace, auto-detects project languages, and writes detailed convention metrics and ratings into the .conventions/ directory.
🚀 Key Features
- 🔍 AST-Backed Convention Scan: Traverses your AST (Python) and code structures (Go, Node, Rust) to detect style patterns, naming strategies, and testing setups.
- 📊 Multi-Language Analysis: Deep-dives into Python, Go, Node.js/TypeScript, and Rust, plus cross-language assets (Docker, Kubernetes, GitHub Actions).
- 🗺️ Architecture Data-Flow Maps: Computes package dependency graphs, detects circular dependencies (DFS), and traces API endpoints down to their database store layers, generating Mermaid flowcharts directly in
CLAUDE.md. - 🤖 Prescriptive Agent Scoping: Generates
CLAUDE.mdand path-scoped rules files in.claude/rules/with imperative instructions and embedded few-shot code evidence blocks—giving agents the exact models they need to mirror. - 📈 Review & Scoring Gate: Rates each detected convention on a 1-5 scale, listing prioritized improvement suggestions. Ideal for local quality audits and CI/CD validation gates.
- 🔌 Pluggable Architecture: Write custom python detectors and rating rule extensions using the plug-in framework.
🤖 CLAUDE.md & Scoped Rules Generation
conventions discover compiles a comprehensive project overview, tech stack, and commands reference directly into CLAUDE.md, alongside directory-scoping rules:
# Generate CLAUDE.md in .claude/ directory
conventions discover --claude
# Or include along with other review formats
conventions discover --format claude
🧠 Few-Shot Agent Optimization
Path-scoped rule files in .claude/rules/*.md and configuration files are optimized specifically for LLM context windows:
- Prescriptive Directives: Observational metrics are converted into imperative instructions (e.g., "Name functions using snake_case style").
- Few-Shot Code Examples: If a convention is detected, the CLI appends the best real-world code snippet from the scanned files, showing the agent exactly how your conventions are implemented.
- Token-Optimized Directory Map: To avoid bloating the main
CLAUDE.md, the full repository file layout is written to.claude/directory-map.mdand referenced via a link. It keeps production code folders uncollapsed while collapsing non-essential directories (tests, docs, workflows) to keep token usage optimal. - Dynamic Decision Log & Pitfalls: Automatically scans git logs, changelogs, release notes, and CI configurations to populate your repository gotchas and architectural decisions, minimizing the need for manual placeholders.
🔄 Enhanced via --init
Add the --init flag to further enrich the generated CLAUDE.md using the Claude Code CLI. This pipes the static-analysis output through Claude to populate additional custom gotchas and decision history:
conventions discover --claude --init
Requires the Claude Code CLI (npm install -g @anthropic-ai/claude-code).
🌐 Language Support
The engine supports 180+ rules across languages and configurations:
| Language/Platform | Rules | Sample Scanned Patterns |
|---|---|---|
| Python | 70+ | typing coverage, docstrings, testing fixtures, stdlib logging, error boundaries, sqlalchemy, context managers, async, dependency injection |
| Node.js/TypeScript | 45+ | TypeScript strictness, jest/vitest frameworks, express/fastify api, mongoose, state management, monorepo workspaces, migrations |
| Go | 40+ | modules, testimony frameworks, stdlib loggers, channels & goroutines, gRPC structures, wire DI, database configurations |
| Rust | 15+ | Cargo configs, tokio async, web frameworks, serialization, macros, unsafe blocks, database ORMs |
| Generic | 20+ | GitHub workflows, pre-commit configuration, git hooks, Docker/Kubernetes files, repository layout |
For the full list of convention IDs, see the Convention ID Reference.
📊 Output Formats & Reports
Scanned results are written to the .conventions/ folder in multiple formats:
| Format | Output File | Description |
|---|---|---|
| json | conventions.raw.json |
Raw, machine-readable JSON representing all rules, stats, and evidence code blocks. |
| markdown | conventions.md |
Human-readable Markdown summary of all detected rules. |
| review | conventions-review.md |
Audit report with scores (1-5), grouped by rating, with prioritized improvement actions. |
| html | conventions.html |
Interactive dashboard with Light/Dark mode, filtering, search, and expandable evidence code blocks. |
| sarif | conventions.sarif |
Static Analysis Results Interchange Format for GitHub Code Scanning and CI uploads. |
📈 Rating Scale
Each convention is evaluated and rated on a 1-5 scale:
- 5 - Excellent: Best practices followed consistently throughout the codebase.
- 4 - Good: Strong alignment with minor improvements possible.
- 3 - Average: Room for improvement; inconsistent usage.
- 2 - Below Average: Significant improvements needed.
- 1 - Poor: Major style or code architecture issues detected.
⚙️ Configuration
Create a .conventionsrc.json configuration file in your repository root to customize behavior:
{
"languages": ["python", "node"],
"max_files": 1000,
"disabled_detectors": ["python_graphql"],
"disabled_rules": ["python.conventions.graphql"],
"output_formats": ["json", "markdown", "review", "html"],
"exclude_patterns": ["**/generated/**", "**/vendor/**"],
"plugin_paths": ["./custom_rules.py"],
"min_score": 3.5
}
🚯 Automatic Exclusions
The CLI respects .gitignore rules and automatically excludes:
node_modules/,vendor/,site-packages/venv/,.venv/,.tox/,.nox/__pycache__/,.pytest_cache/,.mypy_cache/,.ruff_cache/.git/,.svn/,.hg/- Build outputs (
build/,dist/,eggs/) - Examples and docs (
docs/,examples/,tutorials/,demo/,samples/)
🛡️ CI/CD Integration
Use the CLI as a pull request quality gate. When min_score is defined, the scan will fail (exit code 2) if the project-wide average falls below your threshold.
GitHub Actions Workflow:
# .github/workflows/conventions.yml
name: Check Conventions
on: [push, pull_request]
jobs:
conventions:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- run: pip install klaussy-repo-conventions
- run: conventions discover
- run: cat .conventions/conventions-review.md
🔌 Plugin System
Extend the scanner by creating custom Python detectors and rating rules:
# custom_rules.py
from conventions.detectors.base import BaseDetector, DetectorContext, DetectorResult
from conventions.ratings import RatingRule
class MyCustomDetector(BaseDetector):
name = "my_custom_detector"
description = "Detects my custom convention"
languages = {"python"}
def detect(self, ctx: DetectorContext) -> DetectorResult:
result = DetectorResult()
# Custom detection logic
return result
# Required exports
DETECTORS = [MyCustomDetector]
# Optional: custom rating rules
RATING_RULES = {
"custom.my_rule": RatingRule(
score_func=lambda r: 5 if r.stats.get("metric", 0) > 0.8 else 3,
reason_func=lambda r, s: f"Custom metric: {r.stats.get('metric', 0):.0%}",
suggestion_func=lambda r, s: None if s >= 5 else "Improve the custom metric.",
),
}
Add the plugin path to your .conventionsrc.json:
{
"plugin_paths": ["./custom_rules.py"]
}
🤝 Contributing
Contributions are welcome! To add support for new conventions:
- Create a new detector in
src/conventions/detectors/<language>/ - Register it using
@DetectorRegistry.register - Add rating rules in
src/conventions/ratings.py - Add tests in
tests/
⚖️ License & Governance
- License: MIT
- Governance:
klaussy-repo-conventionsis an open-source project owned and maintained by Dovatech LLC (founded and owned by Stephanie Dover).
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file klaussy_repo_conventions-1.5.0.tar.gz.
File metadata
- Download URL: klaussy_repo_conventions-1.5.0.tar.gz
- Upload date:
- Size: 260.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8774d1b38e0fac31100eb224993a155653b09614bec9e9b996a2f4d9262fbfe0
|
|
| MD5 |
0506b49f408d36ea888d611072914f4a
|
|
| BLAKE2b-256 |
ba5d3595e0d0f6e7fafbdd53c0b4a8d4748df0176c4b0de89d4bbff9e4b5b047
|
Provenance
The following attestation bundles were made for klaussy_repo_conventions-1.5.0.tar.gz:
Publisher:
publish.yml on steph-dove/klaussy-repo-conventions
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
klaussy_repo_conventions-1.5.0.tar.gz -
Subject digest:
8774d1b38e0fac31100eb224993a155653b09614bec9e9b996a2f4d9262fbfe0 - Sigstore transparency entry: 2000839961
- Sigstore integration time:
-
Permalink:
steph-dove/klaussy-repo-conventions@a65cc5a57c7adf5d7b9f551756bcf400cde4ee6a -
Branch / Tag:
refs/tags/v1.5.0 - Owner: https://github.com/steph-dove
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a65cc5a57c7adf5d7b9f551756bcf400cde4ee6a -
Trigger Event:
release
-
Statement type:
File details
Details for the file klaussy_repo_conventions-1.5.0-py3-none-any.whl.
File metadata
- Download URL: klaussy_repo_conventions-1.5.0-py3-none-any.whl
- Upload date:
- Size: 342.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0090e652fe2506f2c6ac538f0ba199973bc249f6a57bb85724143ea34cbc9f0a
|
|
| MD5 |
e8bdb3ba56ee0ff56099f6ab9ea09c79
|
|
| BLAKE2b-256 |
a2bdb50ccbbce93e4c8bdcd1708e62340bcbb701aae8bfaee034855191ba5ef6
|
Provenance
The following attestation bundles were made for klaussy_repo_conventions-1.5.0-py3-none-any.whl:
Publisher:
publish.yml on steph-dove/klaussy-repo-conventions
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
klaussy_repo_conventions-1.5.0-py3-none-any.whl -
Subject digest:
0090e652fe2506f2c6ac538f0ba199973bc249f6a57bb85724143ea34cbc9f0a - Sigstore transparency entry: 2000840086
- Sigstore integration time:
-
Permalink:
steph-dove/klaussy-repo-conventions@a65cc5a57c7adf5d7b9f551756bcf400cde4ee6a -
Branch / Tag:
refs/tags/v1.5.0 - Owner: https://github.com/steph-dove
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a65cc5a57c7adf5d7b9f551756bcf400cde4ee6a -
Trigger Event:
release
-
Statement type: