setup

A setup command for adding claudemem search rules to a project's CLAUDE.md file. It checks whether claudemem is installed and indexed before offering to document the project's search requirements.

In plain words
What is it for?
Use it to check installation and index status, initialize or index claudemem when needed, inspect CLAUDE.md, and add enforcement rules with the user's approval.
Why use it?
It helps ensure that code-search enforcement is configured and that the project has a usable claudemem index.

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/madappgang/claude-code/setup
Clone the repo
git clone --depth 1 https://github.com/MadAppGang/claude-code
Per session 17 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 955 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.00017 $0.00955
Opus 5 $0.00009 $0.00477
Sonnet 5 $0.00003 $0.00191
Haiku 4.5 $0.00002 $0.00096

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

Security

Grade A, and why

setup 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.

plugins/code-analysis/commands/setup.md · 142 lines

How it starts

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

Setup Claudemem Enforcement

This command sets up claudemem semantic search enforcement for this project.

Steps

1. Check claudemem installation

which claudemem && claudemem --version

If not installed, guide user:

npm install -g claude-codemem
claudemem init

2. Check index status

claudemem status

If not indexed:

claudemem index

3. Check CLAUDE.md for existing rules

Read the project's CLAUDE.md and look for the marker: ## Code Search: CLAUDEMEM ENFORCED

4. If rules not present, ask user

AskUserQuestion({
  questions: [{
    question: "Add claudemem enforcement rules to CLAUDE.md?",
    header: "Setup",
    multiSelect: false,
    options: [
      { label: "Yes, add rules (Recommended)", description: "Adds documentation about Grep/Glob interception" },
      { label: "No, skip", description: "Hooks will still work, just no documentation in CLAUDE.md" }
    ]
  }]
})

5. Inject rules if user agrees

Append the following to CLAUDE.md:


## Code Search: CLAUDEMEM ENFORCED

> Added by `code-analysis` plugin v2.14.0

### Mandatory Enforcement Rules

**The hook system is INESCAPABLE when claudemem is indexed.**

| Tool | Behavior | Workaround Blocked? |
|------|----------|-------------------|
| **Grep** | BLOCKED - Results provided in block message | N/A (primary) |
| **Glob (code patterns)** | BLOCKED if pattern matches `**/*.ts` etc | YES |
| **Bash grep/rg/find** | BLOCKED - Pattern extracted and analyzed | YES |
| **Read (3+ files)** | WARNING at 3, BLOCKED at 5+ | YES |
| **Task (Explore)** | BLOCKED - Redirect to detective | YES |

### Evasion Detection

The hook system tracks blocked tools and detects workaround patterns:

- Grep blocked -> Glob attempted -> **EVASION BLOCKED**
- Grep blocked -> 5 Read calls -> **BULK READ BLOCKED**
- Explore blocked -> Bash search -> **EVASION BLOCKED**

**There is no workaround. Use claudemem or detective skills.**

### Required Response to Block

When you see a block message:

1. **READ** the provided claudemem results in the block message
2. **USE** those results if sufficient
3. **INVOKE** `code-analysis:claudemem-search` skill if more data needed
4. **NEVER** attempt Glob, bulk Read, or Bash search as alternatives

### Manual Commands

```bash
claudemem search "authentication flow"  # Semantic search
claudemem --agent symbol "UserService"  # Find definition
claudemem --agent callers "login"       # Impact analysis
claudemem status                        # Check index
claudemem index                         # Re-index project

Why This Exists

  1. Token Efficiency: claudemem ~500 tokens vs 5+ files ~5000+ tokens
  2. Semantic Ranking: Results ranked by relevance, not file order
  3. No Noise: Excludes node_modules, generated types, fixtures
  4. AST Analysis: Understands code structure, not just text patterns

Consequences of Ignoring

  • Workaround tools will be blocked
  • Evasion patterns are logged
  • Each block adds context overhead
  • Task fails to progress until compliance

Read the full file on GitHub · 142 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 · 142 lines · 17 tokens per session scan A a05db8b5b4ad

Subscribe to this mod's changes

setup is a command published in the GitHub repository MadAppGang/claude-code (279 stars, last pushed 5mo ago), licensed MIT. It adds 17 tokens to every session and 955 once invoked, about $0.0001 per session on Opus 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.