test

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

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/cognitx-leyton/codegraph/test
Clone the repo
git clone --depth 1 https://github.com/cognitx-leyton/codegraph

Made for: Claude Code.

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. 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.00014 $0.01314
Opus 5 $0.00007 $0.00657
Sonnet 5 $0.00003 $0.00263
Haiku 4.5 $0.00001 $0.00131

Measured yesterday against content hash c81dbae7bea2, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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 yesterday.

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. yesterday 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 (11 stars, last pushed 1mo 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. 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.