claude-code-indexer


Nameclaude-code-indexer JSON
Version 1.2.0 PyPI version JSON
download
home_pagehttps://github.com/anthropics/claude-code-indexer
SummaryCode indexing tool using graph database for Claude Code Assistant
upload_time2025-07-16 05:56:29
maintainerNone
docs_urlNone
authorClaude AI Assistant
requires_python>=3.8
licenseMIT
keywords code-indexing graph-database ensmallen claude code-analysis ast development-tools
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Claude Code Indexer

A powerful code indexing tool that uses graph databases to analyze and understand code structure. Built specifically for Claude Code assistant workflows.

## Features

- 📊 **Graph-based code analysis** using Ensmallen library
- 🔍 **Intelligent node ranking** based on importance and centrality
- 💾 **SQLite database** for persistent storage
- 🎯 **Relevance tagging** for different code entity types
- 📈 **Network analysis** with PageRank and centrality measures
- 🚀 **Easy CLI interface** for quick setup and usage

## Installation

### From PyPI (Recommended)

```bash
pip install claude-code-indexer
```

### From Source

```bash
git clone https://github.com/anthropics/claude-code-indexer.git
cd claude-code-indexer
pip install -e .
```

### Updating

The package includes auto-update functionality:

```bash
# Check for updates
claude-code-indexer update --check-only

# Update to latest version
claude-code-indexer update

# Sync CLAUDE.md with latest template
claude-code-indexer sync
```

Updates will also be checked automatically when you run any command.

## Quick Start

### 1. Initialize in your project

```bash
cd your-project
claude-code-indexer init
```

This will:
- Create or update your `CLAUDE.md` file with indexing instructions
- Initialize the SQLite database
- Add database to `.gitignore`

### 2. Index your codebase

```bash
# Index current directory
claude-code-indexer index .

# Index specific directory
claude-code-indexer index /path/to/your/code

# Index with custom patterns
claude-code-indexer index . --patterns "*.py,*.js,*.ts"
```

### 3. Query your code

```bash
# Show most important code entities
claude-code-indexer query --important

# Show all entities of specific type
claude-code-indexer query --type class

# Search for specific terms
claude-code-indexer search "UserModel"

# View indexing statistics
claude-code-indexer stats
```

## CLI Commands

### `init`
Initialize Claude Code Indexer in current directory.

```bash
claude-code-indexer init [--force]
```

Options:
- `--force`: Overwrite existing configuration

### `index`
Index source code in specified directory.

```bash
claude-code-indexer index PATH [options]
```

Options:
- `--patterns`: File patterns to index (default: "*.py")
- `--db`: Database file path (default: "code_index.db")

### `query`
Query indexed code entities.

```bash
claude-code-indexer query [options]
```

Options:
- `--important`: Show only important nodes
- `--type`: Filter by node type (file, class, method, function)
- `--limit`: Maximum number of results (default: 20)
- `--db`: Database file path

### `search`
Search for code entities by name.

```bash
claude-code-indexer search TERM [options]
```

### `stats`
Show indexing statistics.

```bash
claude-code-indexer stats [--db DATABASE]
```

## Database Schema

The tool creates a SQLite database with the following structure:

### code_nodes
Stores information about code entities.

```sql
CREATE TABLE code_nodes (
    id INTEGER PRIMARY KEY,
    node_type TEXT,           -- 'file', 'class', 'method', 'function', 'import'
    name TEXT,                -- Entity name
    path TEXT,                -- File path
    summary TEXT,             -- Description
    importance_score REAL,    -- 0.0 to 1.0
    relevance_tags TEXT,      -- JSON array of tags
    created_at TIMESTAMP
);
```

### relationships
Stores relationships between code entities.

```sql
CREATE TABLE relationships (
    source_id INTEGER,
    target_id INTEGER,
    relationship_type TEXT,   -- 'imports', 'contains', 'calls', 'inherits'
    weight REAL,
    created_at TIMESTAMP
);
```

## Integration with Claude Code

After running `claude-code-indexer init`, your `CLAUDE.md` file will include:

- Complete setup instructions
- Database schema documentation
- CLI command reference
- Usage examples for Claude Code workflows

## Graph Analysis Features

### Node Importance Scoring
- **Degree centrality**: Based on number of connections
- **PageRank**: Overall importance in the dependency graph
- **Weighted scoring**: Combines multiple centrality measures

### Relevance Tags
- `structural`: Classes and main components
- `highly-used`: Entities with many incoming dependencies
- `complex`: Entities with many outgoing dependencies
- `test`: Test-related code
- `module`: File-level entities

### Advanced Analysis
- **Hub detection**: Find central components in your architecture
- **Dependency tracking**: Understand code relationships
- **Impact analysis**: Trace how changes propagate
- **Similarity detection**: Find related code patterns

## Examples

### Basic Usage

```python
from claude_code_indexer import CodeGraphIndexer

# Create indexer
indexer = CodeGraphIndexer("my_project.db")

# Index a directory
indexer.index_directory("./src")

# Query important nodes
important_nodes = indexer.query_important_nodes(min_score=0.5)
for node in important_nodes:
    print(f"{node['name']} ({node['node_type']}): {node['importance_score']}")
```

### Advanced Analysis

```python
# Get graph statistics
stats = indexer.get_stats()
print(f"Total nodes: {stats['total_nodes']}")
print(f"Node types: {stats['node_types']}")

# Build NetworkX graph for custom analysis
nx_graph = indexer.build_graph()
import networkx as nx
centrality = nx.betweenness_centrality(nx_graph)
```

## Requirements

- Python 3.8+
- ensmallen >= 0.8.0
- networkx >= 3.0
- pandas >= 1.5.0
- click >= 8.0.0
- rich >= 13.0.0

## Contributing

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests
5. Submit a pull request

## License

MIT License - see LICENSE file for details.

## Support

- 📖 [Documentation](https://docs.anthropic.com/claude-code)
- 🐛 [Issues](https://github.com/claude-ai/code-indexer/issues)
- 💬 [Discussions](https://github.com/claude-ai/code-indexer/discussions)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/anthropics/claude-code-indexer",
    "name": "claude-code-indexer",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "Claude Community <noreply@anthropic.com>",
    "keywords": "code-indexing, graph-database, ensmallen, claude, code-analysis, ast, development-tools",
    "author": "Claude AI Assistant",
    "author_email": "Claude AI Assistant <noreply@anthropic.com>",
    "download_url": "https://files.pythonhosted.org/packages/b5/7c/9c8989b314b5bdcc2e37eb52f626d07c89c02379d143be9d5e98d0bdfb21/claude_code_indexer-1.2.0.tar.gz",
    "platform": null,
    "description": "# Claude Code Indexer\n\nA powerful code indexing tool that uses graph databases to analyze and understand code structure. Built specifically for Claude Code assistant workflows.\n\n## Features\n\n- \ud83d\udcca **Graph-based code analysis** using Ensmallen library\n- \ud83d\udd0d **Intelligent node ranking** based on importance and centrality\n- \ud83d\udcbe **SQLite database** for persistent storage\n- \ud83c\udfaf **Relevance tagging** for different code entity types\n- \ud83d\udcc8 **Network analysis** with PageRank and centrality measures\n- \ud83d\ude80 **Easy CLI interface** for quick setup and usage\n\n## Installation\n\n### From PyPI (Recommended)\n\n```bash\npip install claude-code-indexer\n```\n\n### From Source\n\n```bash\ngit clone https://github.com/anthropics/claude-code-indexer.git\ncd claude-code-indexer\npip install -e .\n```\n\n### Updating\n\nThe package includes auto-update functionality:\n\n```bash\n# Check for updates\nclaude-code-indexer update --check-only\n\n# Update to latest version\nclaude-code-indexer update\n\n# Sync CLAUDE.md with latest template\nclaude-code-indexer sync\n```\n\nUpdates will also be checked automatically when you run any command.\n\n## Quick Start\n\n### 1. Initialize in your project\n\n```bash\ncd your-project\nclaude-code-indexer init\n```\n\nThis will:\n- Create or update your `CLAUDE.md` file with indexing instructions\n- Initialize the SQLite database\n- Add database to `.gitignore`\n\n### 2. Index your codebase\n\n```bash\n# Index current directory\nclaude-code-indexer index .\n\n# Index specific directory\nclaude-code-indexer index /path/to/your/code\n\n# Index with custom patterns\nclaude-code-indexer index . --patterns \"*.py,*.js,*.ts\"\n```\n\n### 3. Query your code\n\n```bash\n# Show most important code entities\nclaude-code-indexer query --important\n\n# Show all entities of specific type\nclaude-code-indexer query --type class\n\n# Search for specific terms\nclaude-code-indexer search \"UserModel\"\n\n# View indexing statistics\nclaude-code-indexer stats\n```\n\n## CLI Commands\n\n### `init`\nInitialize Claude Code Indexer in current directory.\n\n```bash\nclaude-code-indexer init [--force]\n```\n\nOptions:\n- `--force`: Overwrite existing configuration\n\n### `index`\nIndex source code in specified directory.\n\n```bash\nclaude-code-indexer index PATH [options]\n```\n\nOptions:\n- `--patterns`: File patterns to index (default: \"*.py\")\n- `--db`: Database file path (default: \"code_index.db\")\n\n### `query`\nQuery indexed code entities.\n\n```bash\nclaude-code-indexer query [options]\n```\n\nOptions:\n- `--important`: Show only important nodes\n- `--type`: Filter by node type (file, class, method, function)\n- `--limit`: Maximum number of results (default: 20)\n- `--db`: Database file path\n\n### `search`\nSearch for code entities by name.\n\n```bash\nclaude-code-indexer search TERM [options]\n```\n\n### `stats`\nShow indexing statistics.\n\n```bash\nclaude-code-indexer stats [--db DATABASE]\n```\n\n## Database Schema\n\nThe tool creates a SQLite database with the following structure:\n\n### code_nodes\nStores information about code entities.\n\n```sql\nCREATE TABLE code_nodes (\n    id INTEGER PRIMARY KEY,\n    node_type TEXT,           -- 'file', 'class', 'method', 'function', 'import'\n    name TEXT,                -- Entity name\n    path TEXT,                -- File path\n    summary TEXT,             -- Description\n    importance_score REAL,    -- 0.0 to 1.0\n    relevance_tags TEXT,      -- JSON array of tags\n    created_at TIMESTAMP\n);\n```\n\n### relationships\nStores relationships between code entities.\n\n```sql\nCREATE TABLE relationships (\n    source_id INTEGER,\n    target_id INTEGER,\n    relationship_type TEXT,   -- 'imports', 'contains', 'calls', 'inherits'\n    weight REAL,\n    created_at TIMESTAMP\n);\n```\n\n## Integration with Claude Code\n\nAfter running `claude-code-indexer init`, your `CLAUDE.md` file will include:\n\n- Complete setup instructions\n- Database schema documentation\n- CLI command reference\n- Usage examples for Claude Code workflows\n\n## Graph Analysis Features\n\n### Node Importance Scoring\n- **Degree centrality**: Based on number of connections\n- **PageRank**: Overall importance in the dependency graph\n- **Weighted scoring**: Combines multiple centrality measures\n\n### Relevance Tags\n- `structural`: Classes and main components\n- `highly-used`: Entities with many incoming dependencies\n- `complex`: Entities with many outgoing dependencies\n- `test`: Test-related code\n- `module`: File-level entities\n\n### Advanced Analysis\n- **Hub detection**: Find central components in your architecture\n- **Dependency tracking**: Understand code relationships\n- **Impact analysis**: Trace how changes propagate\n- **Similarity detection**: Find related code patterns\n\n## Examples\n\n### Basic Usage\n\n```python\nfrom claude_code_indexer import CodeGraphIndexer\n\n# Create indexer\nindexer = CodeGraphIndexer(\"my_project.db\")\n\n# Index a directory\nindexer.index_directory(\"./src\")\n\n# Query important nodes\nimportant_nodes = indexer.query_important_nodes(min_score=0.5)\nfor node in important_nodes:\n    print(f\"{node['name']} ({node['node_type']}): {node['importance_score']}\")\n```\n\n### Advanced Analysis\n\n```python\n# Get graph statistics\nstats = indexer.get_stats()\nprint(f\"Total nodes: {stats['total_nodes']}\")\nprint(f\"Node types: {stats['node_types']}\")\n\n# Build NetworkX graph for custom analysis\nnx_graph = indexer.build_graph()\nimport networkx as nx\ncentrality = nx.betweenness_centrality(nx_graph)\n```\n\n## Requirements\n\n- Python 3.8+\n- ensmallen >= 0.8.0\n- networkx >= 3.0\n- pandas >= 1.5.0\n- click >= 8.0.0\n- rich >= 13.0.0\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes\n4. Add tests\n5. Submit a pull request\n\n## License\n\nMIT License - see LICENSE file for details.\n\n## Support\n\n- \ud83d\udcd6 [Documentation](https://docs.anthropic.com/claude-code)\n- \ud83d\udc1b [Issues](https://github.com/claude-ai/code-indexer/issues)\n- \ud83d\udcac [Discussions](https://github.com/claude-ai/code-indexer/discussions)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Code indexing tool using graph database for Claude Code Assistant",
    "version": "1.2.0",
    "project_urls": {
        "Changelog": "https://github.com/anthropics/claude-code-indexer/blob/main/CHANGELOG.md",
        "Documentation": "https://docs.anthropic.com/claude-code",
        "Homepage": "https://github.com/anthropics/claude-code-indexer",
        "Issues": "https://github.com/anthropics/claude-code-indexer/issues",
        "Repository": "https://github.com/anthropics/claude-code-indexer.git"
    },
    "split_keywords": [
        "code-indexing",
        " graph-database",
        " ensmallen",
        " claude",
        " code-analysis",
        " ast",
        " development-tools"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "1746ccdc97532bb9c67efcf65bb254bf8bbf74fc6ae9061aaf2320c4b8d46c1e",
                "md5": "c675e407124aefac4d46dde84a66f191",
                "sha256": "b22fc1a09edbae41bacc35ce340cc6df421502d7389cacd27e79c26dc24b588b"
            },
            "downloads": -1,
            "filename": "claude_code_indexer-1.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c675e407124aefac4d46dde84a66f191",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 40436,
            "upload_time": "2025-07-16T05:56:28",
            "upload_time_iso_8601": "2025-07-16T05:56:28.514083Z",
            "url": "https://files.pythonhosted.org/packages/17/46/ccdc97532bb9c67efcf65bb254bf8bbf74fc6ae9061aaf2320c4b8d46c1e/claude_code_indexer-1.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "b57c9c8989b314b5bdcc2e37eb52f626d07c89c02379d143be9d5e98d0bdfb21",
                "md5": "2497733a538c995cecf287643a07cc2a",
                "sha256": "88f0023aa21acdf0cc45b49351f36ba2d1744f28ebe97afdf96c0548341a7a7b"
            },
            "downloads": -1,
            "filename": "claude_code_indexer-1.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "2497733a538c995cecf287643a07cc2a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 38273,
            "upload_time": "2025-07-16T05:56:29",
            "upload_time_iso_8601": "2025-07-16T05:56:29.858062Z",
            "url": "https://files.pythonhosted.org/packages/b5/7c/9c8989b314b5bdcc2e37eb52f626d07c89c02379d143be9d5e98d0bdfb21/claude_code_indexer-1.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-16 05:56:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "anthropics",
    "github_project": "claude-code-indexer",
    "github_not_found": true,
    "lcname": "claude-code-indexer"
}
        
Elapsed time: 1.22488s