> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sharc.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Claude Code

> Add SHARC to Claude Code with a single command

Claude Code ships with a first-class MCP CLI. One command and you're done.

## Quick install

```bash theme={null}
claude mcp add sharc -e SHARC_API_KEY=sk_mcp_... -- npx -y @sharc-code/mcp@latest
```

Restart Claude Code and the seven SHARC tools become available.

<Note>
  Use `-s user` to install for your user (available across all projects) or `-s project` to commit a `.mcp.json` to the repo so teammates get it automatically. Default is `local` (this project, your machine).
</Note>

## Verify

```bash theme={null}
claude mcp list
```

Look for a `sharc` entry. From inside Claude Code, ask:

```
> List the MCP tools you have available
```

You should see `index_codebase`, `search_code`, `clear_index`, `get_indexing_status`, `start_watch`, `stop_watch`, `get_watch_status`.

## Manual configuration (alternative)

If you'd rather edit JSON directly, add this to your Claude Code MCP config:

```json theme={null}
{
  "mcpServers": {
    "sharc": {
      "command": "npx",
      "args": ["-y", "@sharc-code/mcp@latest"],
      "env": {
        "SHARC_API_KEY": "sk_mcp_..."
      }
    }
  }
}
```

## Usage examples

### Indexing a codebase

```
> Please index this codebase for semantic search

● index_codebase (MCP)
  path: "/Users/you/project"
  ⎿ Scanning files...
  ⎿ Found 342 files to index
  ⎿ Chunking code (AST-based for .ts, .py, .go...)
  ⎿ Generating embeddings (2,450 chunks)
  ⎿ ✓ Indexed 2,450 chunks in 18.3s
```

### Searching code

```
> How does the authentication middleware work?

● search_code (MCP)
  query: "authentication middleware"
  limit: 3
  ⎿ Found 3 results for query: "authentication middleware"

  1. Code snippet (typescript) [project]
     Location: src/middleware/auth.ts:45-89
     Score: 0.9847
     ... +44 lines (ctrl+o to expand)
```

### Incremental updates

After the initial index, SHARC watches the working tree and re-indexes changed files automatically:

```
> I just modified the auth middleware, is the index updated?

● get_watch_status (MCP)
  ⎿ Watching: /Users/you/project
  ⎿ Last update: 2 seconds ago
```

## Best practices

### Index before deep dives

For the best experience, index before asking complex questions:

```
> Before we start, please index this codebase

[After indexing completes]

> Now, explain the data flow from API request to database
```

### Use natural language queries

SHARC understands semantic meaning, not just keywords:

```
# Good queries:
"How are users authenticated?"
"Where is the database connection configured?"
"Find the error handling for API requests"

# Less effective:
"auth" (too vague)
"config.ts" (use glob patterns for file search)
```

### Adjust result limits

For broad exploration, increase the limit:

```
> Search for all API endpoints with limit 10
```

For specific answers, keep it low (default 3).

## Troubleshooting

### Tools not available

1. Restart Claude Code
2. Run `claude mcp list` and confirm `sharc` is listed
3. Verify the API key is correct: `claude mcp get sharc`

### Slow indexing

Initial indexing time depends on codebase size. The Hono repo takes \~30-45 seconds; large repos like Next.js can take 3-4 minutes. Subsequent runs use Merkle diff for near-instant updates.

### Search returns unexpected results

* Try rephrasing your query semantically
* Use `extensionFilter` to narrow to specific file types
* Check if the codebase is fully indexed with `get_indexing_status`
