Skip to main content

Crader is a production-ready library that transforms source code into a queryable Code Property Graph (CPG) with semantic embeddings. Built for AI-powered code analysis, intelligent retrieval, and agentic workflows.

Project description

Crader

Crader builds a code property graph (CPG) and embeddings from Git repositories. It parses code into semantic chunks, stores them in PostgreSQL with snapshot isolation, and supports hybrid search and graph navigation.

Core capabilities

  • Tree-sitter parsing and chunking with byte-precise ranges
  • SCIP-based relations for cross-file references (current bottleneck for file-incremental indexing; see Roadmap)
  • Full-text index for keyword search
  • Vector embeddings and pgvector search
  • Snapshot-based reads for consistent retrieval
  • Graph navigation helpers (parent blocks, callers, callees)

Requirements

  • Python 3.10+
  • PostgreSQL with the pgvector extension
  • git
  • SCIP CLI and language indexers (scip, scip-python, scip-typescript, scip-java, scip-go, scip-rust, scip-php, scip-clang). This is the current bottleneck for file-incremental indexing; see Roadmap.
  • Optional: OpenAI API key if you use OpenAI embeddings

Install

pip install crader

Database setup

Set the database URL and run the migrations:

export CRADER_DB_URL="postgresql://user:pass@localhost:5432/codebase"
crader db upgrade

The migration enables the vector extension and creates the schema used by the indexer.

Quick start

Index a repository (parsing, chunking, SCIP relations; see Roadmap for the current bottleneck):

crader index https://github.com/pallets/flask.git --branch main

Generate embeddings:

import asyncio
from crader import CodebaseIndexer
from crader.providers.embedding import OpenAIEmbeddingProvider

repo_url = "https://github.com/pallets/flask.git"
branch = "main"

db_url = "postgresql://user:pass@localhost:5432/codebase"
indexer = CodebaseIndexer(repo_url=repo_url, branch=branch, db_url=db_url)

async def main():
    provider = OpenAIEmbeddingProvider(model="text-embedding-3-small")
    async for update in indexer.embed(provider, batch_size=200):
        if update.get("status") == "completed":
            print(update)

asyncio.run(main())
indexer.close()

Search and retrieve context:

from crader import CodeRetriever
from crader.storage.connector import PooledConnector
from crader.storage.postgres import PostgresGraphStorage
from crader.providers.embedding import OpenAIEmbeddingProvider

db_url = "postgresql://user:pass@localhost:5432/codebase"
provider = OpenAIEmbeddingProvider(model="text-embedding-3-small")
connector = PooledConnector(dsn=db_url)
storage = PostgresGraphStorage(connector)
retriever = CodeRetriever(storage, provider)

repo_id = storage.ensure_repository(
    repo_url,
    branch,
    repo_url.rstrip("/").split("/")[-1].replace(".git", ""),
)

results = retriever.retrieve(
    query="How does request routing work?",
    repo_id=repo_id,
    limit=3,
    strategy="hybrid",
    filters={"language": "python"},
)

for hit in results:
    print(hit.file_path, hit.start_line, hit.score)

Keyword search works without embeddings, but CodeRetriever still requires an embedding provider instance.

Supported languages

Crader scans files by extension during indexing:

  • .py
  • .js, .jsx
  • .ts, .tsx
  • .java
  • .go
  • .rs
  • .c, .cpp
  • .php
  • .html, .css

Semantic tagging via Tree-sitter queries is currently provided for Python, JavaScript, and TypeScript. SCIP relations require the relevant SCIP tools to be installed and available on PATH.

SCIP is required today to build cross-file relations.

Configuration

Environment variables used by the runtime:

  • CRADER_DB_URL: PostgreSQL connection string (required by CLI and indexer).
  • CRADER_REPO_VOLUME: Root directory for cached repos and worktrees (defaults to ./sheep_data/repositories).
  • CRADER_OPENAI_API_KEY or OPENAI_API_KEY: OpenAI credentials for embeddings.

License

MIT. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

crader-0.1.0.tar.gz (91.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

crader-0.1.0-py3-none-any.whl (103.1 kB view details)

Uploaded Python 3

File details

Details for the file crader-0.1.0.tar.gz.

File metadata

  • Download URL: crader-0.1.0.tar.gz
  • Upload date:
  • Size: 91.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for crader-0.1.0.tar.gz
Algorithm Hash digest
SHA256 12f852b20c3d38455cb8b48bec82869fe2244fd2c951c43f4964c9aa14746a05
MD5 da96a41995ffc005b34e308d03c4fe6d
BLAKE2b-256 bd66eda638b4779a4e6042372e1a4d8d44303e9b4ea172bd9dd6b796a473af9a

See more details on using hashes here.

Provenance

The following attestation bundles were made for crader-0.1.0.tar.gz:

Publisher: publish-pypi.yml on sheeptechnologies/crader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file crader-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: crader-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 103.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for crader-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7b603d677065d105f6b834ec3ae373a0075dfd169bd328c3a1707deb57ec1152
MD5 f50c89ff2f8beddbd82f47b555d34dea
BLAKE2b-256 19a92a1d08e180733717821ec45e348da4f1b8693acecd4301bb316c6b5293a4

See more details on using hashes here.

Provenance

The following attestation bundles were made for crader-0.1.0-py3-none-any.whl:

Publisher: publish-pypi.yml on sheeptechnologies/crader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page