audit

A command that analyzes a codebase and produces scored code-quality reports for automated checks.

In plain words
What is it for?
Use it to check complexity, duplication, coverage, documentation, and other categories in text, JSON, or Markdown, either for the whole codebase or only changed files.
Why use it?
It lets teams detect quality problems before commits or deployments and enforce a minimum score in continuous integration, the automated build-and-test process.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/agentis-tools/ctx/audit
Clone the repo
git clone --depth 1 https://github.com/agentis-tools/ctx
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,103 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.01103
Opus 5 $0.00000 $0.00551
Sonnet 5 $0.00000 $0.00221
Haiku 4.5 $0.00000 $0.00110

Measured 2d ago against content hash 72a00f9b9857, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

audit scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

docs/commands/audit.md · 190 lines

How it starts

The opening of the file, as written. The whole thing — 190 lines — stays where its author put it; the contents beside it link to each section on GitHub.

ctx audit

Run automated code quality analysis with scoring for CI integration.

Synopsis

ctx audit [OPTIONS]

Description

The audit command analyzes your codebase for quality metrics and generates a report with scores. Use it to:

  • Quality gates - Block commits/deploys below a threshold
  • CI integration - Automated quality checks in pipelines
  • Progress tracking - Monitor code quality over time
  • Pre-commit hooks - Catch issues before committing

Prerequisites

Index your codebase first:

ctx index

For full analysis (complexity, modularity), the index creates the analytics database automatically.

Options

Option Description Default
-o, --output <FORMAT> Output format: text, json, markdown text
--min-score <SCORE> Minimum score threshold (0.0-10.0) none
--categories <LIST> Categories to check (comma-separated) all
--incremental Only audit changed files false

Categories

Category Weight Description
complexity 25% Function complexity (fan-out)
duplication 20% Code duplication patterns
coverage 20% Documentation coverage
modularity 20% Module coupling
naming 15% Naming convention adherence

Examples

Basic Audit

ctx audit

Output:

Code Quality Audit
==================

Overall Score: 7.8/10

Categories:
  Complexity:   7.5/10  (5 issues)
  Duplication:  8.0/10  (2 issues)
  Coverage:     6.5/10  (12 issues)
  Modularity:   9.0/10  (1 issues)
  Naming:       8.5/10  (3 issues)

Critical Issues (2):
  [CRIT] src/parser.rs:142 - extract_symbols: fan-out 48 (threshold: 20)
  [CRIT] src/main.rs:809 - run_query: fan-out 45 (threshold: 20)

Warnings (8):
  [WARN] src/db.rs:234 - High coupling: 25 outgoing dependencies
  ...

Quality Gate

# Fail if score below 7.0
ctx audit --min-score 7.0

# In CI, this returns exit code 1 if below threshold
echo $?  # 0 = passed, 1 = failed

Read the full file on GitHub · 190 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 190 lines · 0 tokens per session scan A 72a00f9b9857

Subscribe to this mod's changes

audit is a command published in the GitHub repository agentis-tools/ctx (11 stars, last pushed 15d ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 1,103 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.