update-code-index

update-code-index is a command for coding agents from alinaqi/maggy. It costs 0 tokens per session (2,105 once invoked), scanned A, original, MIT.

A command that scans a codebase and creates or updates CODE_INDEX.md, a guide to the code's functions, classes, hooks, and components grouped by what they do.

In plain words
What is it for?
Finding exported JavaScript, TypeScript, React, or Python code and organizing it into a capability-based index.
Why use it?
It makes existing code easier to find and helps prevent writing a second piece of code that already performs the same job.

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/alinaqi/maggy/update-code-index
Clone the repo
git clone --depth 1 https://github.com/alinaqi/maggy

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 update-code-index

README.md
[![agentmods](https://agentmods.dev/badge/commands/alinaqi/maggy/update-code-index.svg)](https://agentmods.dev/commands/alinaqi/maggy/update-code-index)
Your own site
<a href="https://agentmods.dev/commands/alinaqi/maggy/update-code-index"><img src="https://agentmods.dev/badge/commands/alinaqi/maggy/update-code-index.svg" alt="Measured on agentmods" height="20"></a>
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 2,105 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.02105
Opus 5 $0.00000 $0.01052
Sonnet 5 $0.00000 $0.00421
Haiku 4.5 $0.00000 $0.00211

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

Security

Grade A, and why

update-code-index 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 5d 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.

commands/update-code-index.md · 348 lines

How it starts

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

Update Code Index

Regenerates CODE_INDEX.md by scanning the codebase for all functions, classes, hooks, and components. Organizes by capability to prevent semantic duplication.


What This Command Does

  1. Scans source files - Finds all exported functions, classes, hooks, components
  2. Extracts docstrings - Gets descriptions from JSDoc/docstrings
  3. Categorizes by capability - Groups by what things DO, not where they live
  4. Generates CODE_INDEX.md - Creates/updates the semantic index

Phase 1: Detect Project Type

# Check language
ls package.json pyproject.toml 2>/dev/null

# Check source directories
ls -d src/ lib/ app/ 2>/dev/null

Phase 2: Scan Codebase

For TypeScript/JavaScript

Scan for exports:

# Find all exported functions
grep -rn "export function\|export const\|export class\|export default" src/ --include="*.ts" --include="*.tsx" --include="*.js" --include="*.jsx"

# Find React hooks
grep -rn "export function use[A-Z]\|export const use[A-Z]" src/ --include="*.ts" --include="*.tsx"

# Find React components (PascalCase exports)
grep -rn "export function [A-Z]\|export const [A-Z].*=.*=>" src/ --include="*.tsx" --include="*.jsx"

For Python

# Find all function definitions
grep -rn "^def \|^async def \|^class " src/ --include="*.py"

# Check __all__ exports
grep -rn "__all__" src/ --include="*.py"

Phase 3: Extract Documentation

For each found export, extract:

  1. Name - Function/class name
  2. Location - File path and line number
  3. Description - From JSDoc @description or first line of docstring
  4. Parameters - Function signature
  5. Returns - Return type if available

TypeScript Example

/**
 * Formats a date into a human-readable relative string.
 * @param date - The date to format
 * @returns Relative time string like "2 days ago"
 */
export function formatRelative(date: Date): string {

Extract:

  • Name: formatRelative
  • Description: "Formats a date into a human-readable relative string"
  • Params: (date: Date)
  • Returns: string

Read the full file on GitHub · 348 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. 5d ago First seen · 348 lines · 0 tokens per session scan A c66776076808

Subscribe to this mod's changes

update-code-index is a command published in the GitHub repository alinaqi/maggy (705 stars, last pushed 17d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,105 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.