check

A command that checks an indexed codebase against architecture rules stored in a TOML configuration file. TOML is a human-readable format for settings and rules.

In plain words
What is it for?
Use it to enforce architectural layers, protect legacy modules from new dependents, cap code complexity, and check only files affected by a change in a pull request.
Why use it?
It catches dependencies that break the intended design, such as a domain layer importing infrastructure code. It can also enforce limits on complexity and symbol counts.

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/check
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,157 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.01157
Opus 5 $0.00000 $0.00579
Sonnet 5 $0.00000 $0.00231
Haiku 4.5 $0.00000 $0.00116

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

Security

Grade A, and why

check 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/check.md · 153 lines

How it starts

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

ctx check

Enforce architecture rules from .ctx/rules.toml against the code intelligence index.

Synopsis

ctx check [OPTIONS]

Description

The check command loads a declarative rules file, builds a file-level dependency set from the index (resolved call/implements/extends/uses edges plus resolved imports), evaluates the rules, and reports every violation. Use it to:

  • Enforce layering - e.g. the domain layer must never import infrastructure
  • Freeze legacy code - forbid new dependents of modules slated for removal
  • Cap complexity - fail when fan-in, fan-out, complexity, or file symbol counts exceed limits
  • Gate PRs - with --against, only violations touching changed files are reported

Prerequisites

Index your codebase first:

ctx index

Rules File

Rules live in .ctx/rules.toml (override with --rules):

version = 1

[layers]                                   # layer name -> globs over indexed files
domain         = ["src/domain/**"]
application    = ["src/app/**"]
infrastructure = ["src/infra/**", "src/db/**"]

[[rules.forbidden]]                        # `from` must not depend on `to`
from   = "domain"
to     = "infrastructure"
reason = "Domain layer must stay persistence-agnostic"

[[rules.allowed_dependents]]               # only `only` may depend on `layer`
layer = "infrastructure"                   # (files in no layer are exempt)
only  = ["application"]

[[rules.limit]]                            # metric thresholds
metric  = "fan_in"                         # fan_in | fan_out | complexity | file_symbols
scope   = "symbol"                         # symbol | file
max     = 25
exclude = ["src/core/**"]

[[rules.no_new_dependents]]                # frozen paths
paths  = ["src/legacy/**"]
reason = "Legacy module is frozen; do not add new callers"

Layers must not overlap: a file matching two layers' globs is a configuration error.

Options

Option Description Default
--rules <PATH> Path to the rules file .ctx/rules.toml
--against <REF> Only report violations where at least one endpoint's file changed since REF (for no_new_dependents: where the new dependent changed) none
--list Print the parsed rules and layer membership counts, then exit 0 false
--json Machine-readable output (global flag) false

Read the full file on GitHub · 153 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 · 153 lines · 0 tokens per session scan A 875057e3848e

Subscribe to this mod's changes

check 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,157 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.