Skip to main content

Code auditing and quality rules for AXM

Project description

AXM Logo

axm-audit — Code auditing and quality rules for Python projects

CI axm-audit axm-init Coverage PyPI Python 3.12+ Docs


axm-audit audits Python project quality across 10 scored categories, producing a composite 0–100 score with an A–F grade. It works as a CLI, Python API, and MCP tool for AI agents.

📖 Full documentation

Features

  • 🔍 Linting — Ruff analysis (800+ rules)
  • 🔒 Type Checking — Strict mypy (per-project pyproject.toml config)
  • 📊 Complexity — Cyclomatic complexity via radon (Python API with subprocess fallback)
  • 🛡️ Security — Bandit integration + hardcoded secrets detection
  • 📦 Dependencies — Vulnerability scanning (pip-audit) + hygiene (deptry)
  • 🧪 Testing — Coverage enforcement via pytest-cov
  • 🏗️ Architecture — Circular imports, god classes, coupling metrics, duplication detection
  • 📐 Practices — Docstring coverage, bare except detection, hardcoded secrets, blocking I/O, logging presence, test mirroring
  • 🔧 Tooling — CLI tool availability checks
  • 📈 Composite Scoring — Weighted 10-category 0–100 score with A–F grade

Installation

uv add axm-audit

Quick Start

CLI

# Full audit
axm-audit audit .

# JSON output
axm-audit audit . --json

# Agent-optimized output (compact, actionable)
axm-audit audit . --agent

# Filter by category
axm-audit audit . --category lint

# Run tests with structured output (agent-optimized)
axm-audit test . --mode=compact

Python API

from pathlib import Path
from axm_audit import audit_project

result = audit_project(Path("."))

print(f"Grade: {result.grade} ({result.quality_score:.1f}/100)")
print(f"Checks: {result.total - result.failed}/{result.total} passed")

for check in result.checks:
    if not check.passed:
        print(f"  ❌ {check.rule_id}: {check.message}")
        if check.fix_hint:
            print(f"     Fix: {check.fix_hint}")

MCP (AI Agent)

axm-audit is available as an MCP tool via axm-mcp. AI agents can call audit(path) or verify(path) directly:

# Agent-optimized output: passed checks as compact strings,
# failed checks as dicts with rule_id, message, details, fix_hint
from axm_audit.formatters import format_agent

data = format_agent(result)
# data["score"], data["grade"], data["passed"], data["failed"]

See the MCP how-to guide for details.

Scoring Model

10-category weighted composite on a 100-point scale:

Category Weight Tool
Linting 20% Ruff
Type Safety 15% mypy
Complexity 15% radon
Security 10% Bandit
Dependencies 10% pip-audit + deptry
Testing 15% pytest-cov
Architecture 10% AST analysis
Practices 5% AST analysis

Categories

Category Rules Count
lint LintingRule, FormattingRule, DiffSizeRule, DeadCodeRule 4
type TypeCheckRule 1
complexity ComplexityRule 1
security SecurityRule (Bandit), SecurityPatternRule 2
deps DependencyAuditRule, DependencyHygieneRule 2
testing TestCoverageRule 1
architecture CircularImportRule, GodClassRule, CouplingMetricRule, DuplicationRule 4
practices DocstringCoverageRule, BareExceptRule, BlockingIORule, LoggingPresenceRule, TestMirrorRule 5
structure PyprojectCompletenessRule 1
tooling ToolAvailabilityRule 3

Witness Rules

axm-audit ships a witness rule for use with the axm.witnesses entry point group:

Rule Entry point key Default categories
AuditQualityRule audit_quality lint, type

AuditQualityRule runs audit_project for each configured category independently (a lint failure does not prevent type checking) and returns structured agent-friendly feedback via format_agent.

Development

This package is part of the axm-forge workspace.

git clone https://github.com/axm-protocols/axm-forge.git
cd axm-forge
uv sync --all-groups
uv run --package axm-audit --directory packages/axm-audit pytest -x -q

License

Apache-2.0 — © 2026 axm-protocols

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

axm_audit-0.7.0.tar.gz (107.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

axm_audit-0.7.0-py3-none-any.whl (59.8 kB view details)

Uploaded Python 3

File details

Details for the file axm_audit-0.7.0.tar.gz.

File metadata

  • Download URL: axm_audit-0.7.0.tar.gz
  • Upload date:
  • Size: 107.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for axm_audit-0.7.0.tar.gz
Algorithm Hash digest
SHA256 0fe4248705e329af9b9fad543dec4fe61b436a2ea024fd2b46ccbf684c5a75f9
MD5 ba535d99fc897b0320dd458a0654aaba
BLAKE2b-256 3a0f6b586fd4ba929d7e51320a87f752c0e964e607897990ff634a80a1b2f649

See more details on using hashes here.

Provenance

The following attestation bundles were made for axm_audit-0.7.0.tar.gz:

Publisher: publish.yml on axm-protocols/axm-forge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file axm_audit-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: axm_audit-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 59.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for axm_audit-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d94e2dfaf51cf07633d3d62f9f6c066a71e49714ecba2e19e83715f532377ecc
MD5 c20fcc9d218e94b09e91cb4790910502
BLAKE2b-256 62b4d2e5a5379703ad9a1a96a241106706a66d77fa7d8df5db82e41f3dc7e3d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for axm_audit-0.7.0-py3-none-any.whl:

Publisher: publish.yml on axm-protocols/axm-forge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page