codegraph: Command for Claude Code

.claude/commands/test.md

test is a command for Claude Code from cognitx-leyton/codegraph. It costs 14 tokens per session (1,314 once invoked), scanned C, original, Apache-2.0.

A staged test command that runs project tests, checks that Python files compile, verifies the published package can be installed, and performs real-world indexing checks when requested. A published package is software distributed through a package repository.

In plain words
What is it for?
Use it for all validation or for a selected scope, including unit tests, compilation checks, package-install checks, and codegraph or leytongo indexing validation.
Why use it?
It catches failures at several points: in the code, during installation, and when the software is used on real data.

Command for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: positional $N argument; mentions Claude Code.

This is cognitx-leyton/codegraph's own configuration. It tells Claude Code how to work on codegraph itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything codegraph configures →

Reuse

Borrowing it

Nothing to install: this file belongs to cognitx-leyton/codegraph. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/cognitx-leyton/codegraph/main/.claude/commands/test.md
Clone the repo
git clone --depth 1 https://github.com/cognitx-leyton/codegraph

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for test

README.md
[![agentmods](https://agentmods.dev/badge/commands/cognitx-leyton/codegraph/test/github.svg)](https://agentmods.dev/commands/cognitx-leyton/codegraph/test)
Your own site
<a href="https://agentmods.dev/commands/cognitx-leyton/codegraph/test"><img src="https://agentmods.dev/badge/commands/cognitx-leyton/codegraph/test/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for test

Your own site · 80×15
<a href="https://agentmods.dev/commands/cognitx-leyton/codegraph/test"><img src="https://agentmods.dev/badge/commands/cognitx-leyton/codegraph/test.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 14 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,314 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 1 finding. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00014 $0.01314
Opus 5.5 $0.00006 $0.00526
Sonnet 5.5 $0.00003 $0.00263
Haiku 4.5 $0.00001 $0.00131

Measured 2mo ago against content hash c81dbae7bea2, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade C, and why

test scanned grade C with 1 finding 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 2mo 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.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

rm -rf "$_tmpdir"
.claude/commands/test.md · 141 lines

How it starts

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

Test (Step 10)

Scope: $ARGUMENTS (default: all)

Run progressive validation — from unit tests through real-world indexing.

Stage 1: Unit Tests

cd codegraph
.venv/bin/python -m pytest tests/ -q
python -m compileall codegraph/ -q

Pass criteria: All tests pass, zero warnings, byte-compile clean.

Stage 2: Install Test

Test that the published package is installable with version assertion and retry for PyPI propagation lag:

SCOPE="${ARGUMENTS:-all}"
if [[ "$SCOPE" != "all" && "$SCOPE" != "install" && "$SCOPE" != "" ]]; then
  echo "SKIP: install test (scope is '$SCOPE', not 'install' or 'all')"
else

LATEST=$(grep '^version' pyproject.toml | sed 's/.*"\(.*\)"/\1/')
MAX_ATTEMPTS=3
BACKOFF=15
INSTALL_OK=false

for attempt in $(seq 1 $MAX_ATTEMPTS); do
  _tmpdir=$(mktemp -d)
  TMPVENV="$_tmpdir/venv"
  python3 -m venv "$TMPVENV"
  "$TMPVENV/bin/pip" install "cognitx-codegraph[python]==$LATEST" --no-cache-dir -q

  INSTALLED=$("$TMPVENV/bin/pip" show cognitx-codegraph 2>/dev/null | grep '^Version:' | awk '{print $2}')
  INSTALLED=${INSTALLED:-NONE}
  rm -rf "$_tmpdir"

  if [ "$INSTALLED" = "$LATEST" ]; then
    echo "Install OK — version $INSTALLED verified (attempt $attempt/$MAX_ATTEMPTS)"
    INSTALL_OK=true
    break
  fi

  if [ "$attempt" -lt "$MAX_ATTEMPTS" ]; then
    echo "Attempt $attempt/$MAX_ATTEMPTS: expected $LATEST, got $INSTALLED. Retrying in ${BACKOFF}s..."
    sleep $BACKOFF
    BACKOFF=$((BACKOFF * 2))
  else
    echo "Install FAILED — expected $LATEST but got $INSTALLED after $MAX_ATTEMPTS attempts"
    exit 1
  fi
done

fi

Pass criteria: Installed version matches pyproject.toml version exactly. Retries up to 3 times with exponential backoff (15s, 30s) for PyPI propagation lag.

Note: The exit 1 ensures a non-zero exit in standalone / CI contexts. When run as a Claude Code slash command, Claude also reads the "Install FAILED" echo to determine the outcome.

Tip: Run /test unit to skip the install test during local development.

Read the full file on GitHub · 141 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. 2mo ago First seen · 141 lines · 14 tokens per session scan C c81dbae7bea2

Subscribe to this mod's changes

test is a command published in the GitHub repository cognitx-leyton/codegraph (12 stars, last pushed 3mo ago), licensed Apache-2.0. It adds 14 tokens to every session and 1,314 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it C with 1 finding (recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.