codesage-reindex

codesage-reindex is a command for Claude Code from iliaal/codesage. It costs 28 tokens per session (872 once invoked), scanned A, original, MIT.

A command that refreshes an existing CodeSage search index incrementally, meaning it updates only what changed. It can remove leftover search tables when the configured embedding model changes.

In plain words
What is it for?
Refresh a project's index, detect model mismatches, clean obsolete search data, and report the indexing result.
Why use it?
It provides an immediate update when automatic version-control hooks did not run and avoids rebuilding the whole index for routine changes.

Command for Claude Code

Written for Claude Code: argument-hint in frontmatter.

Part of the codesage-tools plugin — 1 skill, 10 commands, 2 agents, 1 hook shipped together

Good fit Refresh a project's index, detect model mismatches, clean obsolete search data, and report the indexing result.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/iliaal/codesage/codesage-reindex
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.

Clone the repo
git clone --depth 1 https://github.com/iliaal/codesage

Made for: Claude Code.

Or install codesage-tools, the plugin that ships this one along with the rest of its 1 skill, 10 commands, 2 agents, 1 hook.

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 codesage-reindex

README.md
[![agentmods](https://agentmods.dev/badge/commands/iliaal/codesage/codesage-reindex/github.svg)](https://agentmods.dev/commands/iliaal/codesage/codesage-reindex)
Your own site
<a href="https://agentmods.dev/commands/iliaal/codesage/codesage-reindex"><img src="https://agentmods.dev/badge/commands/iliaal/codesage/codesage-reindex/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 codesage-reindex

Your own site · 80×15
<a href="https://agentmods.dev/commands/iliaal/codesage/codesage-reindex"><img src="https://agentmods.dev/badge/commands/iliaal/codesage/codesage-reindex.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 28 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 872 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. 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.00028 $0.00872
Opus 5.5 $0.00011 $0.00349
Sonnet 5.5 $0.00006 $0.00174
Haiku 4.5 $0.00003 $0.00087

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

Security

Grade A, and why

codesage-reindex 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 27d 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.

plugins/codesage-tools/commands/codesage-reindex.md · 46 lines

How it starts

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

Refresh a CodeSage index

Resolve $ARGUMENTS to an absolute project path, defaulting to the current directory. Require .codesage/index.db; otherwise direct the user to /codesage-onboard. Run commands from that project directory.

Before touching .codesage/, reject symlinked directories and symlinked or non-regular leaves, including configuration, database companions, and indexing.lock. Use test -L to detect dangling links as well. Do not follow repository-controlled links when capturing state or running maintenance.

Capture the baseline

Run codesage status --json. Record files, chunks, and semantic.model. These are retained index totals, not the amount processed by the next indexing pass. Preserve any status failure; do not substitute zero for an unavailable baseline.

Index

Run codesage index --lock-wait 30. This uses the project's indexing lock, waiting up to 30 seconds for an existing writer. Exit 75 means contention prevented the pass; report it without claiming an index refresh. Do not remove the lock file or database to bypass contention.

Read both the exit status and the structural/semantic summaries. A successful process can still report failed files. Report named failures, syntax-error recovery counts, and whether further work is needed. If the operation takes more than 30 seconds, use the host's background process handle and poll that same handle.

The index summaries describe this pass:

  • Structural: N files (X skipped, Y failed, Z removed), S symbols, R references records structural work performed. An optional D parsed with syntax errors suffix identifies recovered parses, not failed files.
  • Semantic: N files (X skipped, Y failed, Z removed), C chunks records semantic work performed. C is chunks created during this pass, not the retained index total.
  • Feature and trust-boundary summaries describe their own work; preserve their failures and warnings too.

Clean orphan tables after successful indexing

Only after indexing succeeds without failed files, run codesage cleanup --dry-run. Its Active model: and Active table: identify the configured model, keep: identifies its table, and DRY-RUN drop: identifies orphan tables.

Read the full file on GitHub · 46 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. 27d ago Changed ab3b7bdbd939
  2. 1mo ago Changed · -33 lines · -5 tokens per session 6f8627643786
  3. 1mo ago Changed · +2 lines fde26c5a7715
  4. 1mo ago First seen · 77 lines · 33 tokens per session scan A 475167c1d806

Subscribe to this mod's changes

codesage-reindex is a command published in the GitHub repository iliaal/codesage (21 stars, last pushed yesterday), licensed MIT. It adds 28 tokens to every session and 872 once invoked, about $0.0001 per session on Opus 5.5. 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.