### MCP Server Quickstart: Docker Compose Source: https://github.com/falkordb/code-graph/blob/staging/README.md Instructions to start the FalkorDB service and attach to the `cgraph-mcp` server via stdio using Docker Compose. The server auto-boots FalkorDB if needed. ```bash docker compose up -d falkordb # start the DB ``` ```bash docker compose --profile mcp run --rm -i code-graph-mcp # attach via stdio ``` -------------------------------- ### Install Backend and Frontend Dependencies Source: https://github.com/falkordb/code-graph/blob/staging/README.md Installs all required backend dependencies using 'uv sync' with all extras, and frontend dependencies using 'npm install' in the './app' directory. Optionally installs Playwright dependencies. ```bash # Install backend dependencies uv sync --all-extras # Install frontend dependencies npm install --prefix ./app # Optional: install Playwright dependencies from the repo root npm install ``` -------------------------------- ### Install cgraph CLI Source: https://github.com/falkordb/code-graph/blob/staging/skills/code-graph/references/management.md Install the command-line interface for interacting with the Code Graph. Use `pipx` for global installation or `pip` for project-specific installation. ```bash pipx install falkordb-code-graph ``` ```bash pip install falkordb-code-graph ``` -------------------------------- ### MCP Server Quickstart: Claude Code Source: https://github.com/falkordb/code-graph/blob/staging/README.md Steps to install the `cgraph` package and register the `cgraph-mcp` server with Claude Code. Configure environment variables for database connection and auto-indexing. ```bash pip install falkordb-code-graph # or: uv pip install falkordb-code-graph ``` ```bash claude mcp add-json code-graph '{ "command": "cgraph-mcp", "env": { "FALKORDB_HOST": "localhost", "FALKORDB_PORT": "6379", "CODE_GRAPH_AUTO_INDEX": "true" } }' ``` ```bash cd /path/to/your/repo cgraph init-agent # writes CLAUDE.md and .cursorrules ``` -------------------------------- ### Install Dependencies with Make Source: https://github.com/falkordb/code-graph/blob/staging/CLAUDE.md Use `make install` to install all project dependencies, including Python and Node.js packages. `make install-cli` installs only the CLI entry point. ```bash make install # Install all deps (uv sync + npm install) make install-cli # Install cgraph CLI entry point ``` -------------------------------- ### Install Dependencies Source: https://github.com/falkordb/code-graph/blob/staging/_autodocs/INDEX.md Install all project dependencies, including the command-line interface (CLI) and frontend build assets. Use the dev build for active development. ```bash make install ``` ```bash make install-cli ``` ```bash make build-dev ``` -------------------------------- ### Install and Run Code Graph CLI Source: https://github.com/falkordb/code-graph/blob/staging/CLAUDE.md Install the Code Graph CLI using pipx or pip. For development, use make install-cli or uv pip install -e . ```bash pipx install falkordb-code-graph ``` ```bash pip install falkordb-code-graph ``` ```bash make install-cli ``` ```bash uv pip install -e . ``` -------------------------------- ### Install CLI Tool from Local Clone Source: https://github.com/falkordb/code-graph/blob/staging/README.md Install the `cgraph` CLI tool from a local source code clone using `make` or `uv`. ```bash make install-cli ``` ```bash uv pip install -e . ``` -------------------------------- ### Install Backend Dependencies with Pip Source: https://github.com/falkordb/code-graph/blob/staging/README.md Alternative method to install backend dependencies using pip if 'uv' is not used. Includes test dependencies. ```bash pip install -e ".[test]" ``` -------------------------------- ### Example Python Configuration for Development Source: https://github.com/falkordb/code-graph/blob/staging/_autodocs/SUMMARY.txt Shows a sample configuration for a development environment. Assumes Linux/macOS shell syntax. ```python export DB_BACKEND=falkordb export DB_HOST=localhost export DB_PORT=5432 export DB_USER=user export DB_PASSWORD=password export DB_NAME=graphdb export GRAPH_DB_PATH=/data/graph.db export PROJECT_DB_PATH=/data/project.db export ANALYZER_DB_PATH=/data/analyzer.db export CACHE_SIZE=1024 export LOG_LEVEL=DEBUG export LOG_FILE=/var/log/codegraph.log export MAX_THREADS=4 export MAX_ITERATIONS=1000 export ENABLE_PROFILING=false export ENABLE_METRICS=false export METRICS_PORT=9090 export AUTH_MODE=bearer export JWT_SECRET=mysecretkey ``` -------------------------------- ### Example Docker Configuration Source: https://github.com/falkordb/code-graph/blob/staging/_autodocs/SUMMARY.txt Provides an example configuration for running CodeGraph within a Docker environment. Assumes Linux/macOS shell syntax. ```shell docker run -d \ -p 8080:8080 \ -e DB_BACKEND=falkordb \ -e DB_HOST=falkordb-db \ -e DB_PORT=5432 \ -e DB_USER=user \ -e DB_PASSWORD=password \ -e DB_NAME=graphdb \ -e GRAPH_DB_PATH=/data/graph.db \ -e PROJECT_DB_PATH=/data/project.db \ -e ANALYZER_DB_PATH=/data/analyzer.db \ -e CACHE_SIZE=1024 \ -e LOG_LEVEL=INFO \ -e LOG_FILE=/var/log/codegraph.log \ -e MAX_THREADS=4 \ -e MAX_ITERATIONS=1000 \ -e ENABLE_PROFILING=false \ -e ENABLE_METRICS=false \ -e METRICS_PORT=9090 \ -e AUTH_MODE=bearer \ -e JWT_SECRET=mysecretkey \ falkordb/codegraph:latest ``` -------------------------------- ### Install CLI Tool from PyPI Source: https://github.com/falkordb/code-graph/blob/staging/README.md Install the `cgraph` CLI tool using pipx or pip. Recommended for end users. ```bash pipx install falkordb-code-graph ``` ```bash pip install falkordb-code-graph ``` -------------------------------- ### Install cgraph CLI for Development (Troubleshooting) Source: https://github.com/falkordb/code-graph/blob/staging/skills/code-graph/references/management.md If the `cgraph` command is not found, ensure the package is installed correctly. This command is for development installations from a local clone. ```bash uv pip install -e . # from the code-graph repo ``` -------------------------------- ### HTTP Request/Response Example Source: https://github.com/falkordb/code-graph/blob/staging/_autodocs/INDEX.md Provides an example of an HTTP POST request to the `/api/get_neighbors` endpoint and its expected JSON response. ```APIDOC ## HTTP Request/Response This section details an example HTTP request and its response for retrieving neighbors. ### Endpoint `POST /api/get_neighbors` ### Request Example ```bash curl -X POST http://localhost:5000/api/get_neighbors \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $TOKEN" \ -d '{ "repo": "my-project", "node_ids": [1, 2], "branch": "main" }' ``` ### Request Body Parameters - **repo** (string) - Required - The repository name. - **node_ids** (array of integers) - Required - The list of node IDs. - **branch** (string) - Optional - The branch name. ### Response Example (Success) ```json { "status": "success", "branch": "main", "neighbors": { "nodes": [...], "edges": [...] } } ``` ### Response Body Fields (Success) - **status** (string) - The status of the request. - **branch** (string) - The branch name. - **neighbors** (object) - Contains nodes and edges related to the query. ``` -------------------------------- ### Install cgraph CLI for Development Source: https://github.com/falkordb/code-graph/blob/staging/skills/code-graph/references/management.md Install the cgraph CLI from a local clone of the repository for development purposes. This ensures you are using the latest code. ```bash cd /path/to/code-graph uv sync --all-extras uv pip install -e . ``` -------------------------------- ### Verify cgraph CLI Installation Source: https://github.com/falkordb/code-graph/blob/staging/skills/code-graph/references/management.md Run this command after installation to confirm that the cgraph CLI is accessible and working correctly. ```bash cgraph --help ``` -------------------------------- ### Python Client Example for Sync and Async Usage Source: https://github.com/falkordb/code-graph/blob/staging/_autodocs/SUMMARY.txt Demonstrates how to use the Python client for both synchronous and asynchronous operations. Requires Python 3.12+ syntax and FalkorDB/Cypher knowledge. ```python from falkordb import FalkorDB # Sync example db_sync = FalkorDB(host='localhost', port=5432, database='graphdb', user='user', password='password') result_sync = db_sync.query('MATCH (n) RETURN n LIMIT 1') print(result_sync) # Async example async def run_async(): db_async = FalkorDB(host='localhost', port=5432, database='graphdb', user='user', password='password') result_async = await db_async.query_async('MATCH (n) RETURN n LIMIT 1') print(result_async) import asyncio asyncio.run(run_async()) ``` -------------------------------- ### Install cgraph CLI Source: https://github.com/falkordb/code-graph/blob/staging/_autodocs/cli-reference.md Install the cgraph CLI tool using pipx for end users or via make install-cli/uv pip install for local development. ```bash pipx install falkordb-code-graph ``` ```bash make install-cli ``` ```bash uv pip install -e . ``` -------------------------------- ### CLI Command Example with JSON Output Source: https://github.com/falkordb/code-graph/blob/staging/_autodocs/SUMMARY.txt Demonstrates a command-line interface command and its expected JSON output format. Useful for CLI users. ```shell # Example CLI command cgraph analyze --project /path/to/project --language python # Example JSON output { "status": "success", "message": "Analysis complete.", "data": { "nodes": 150, "edges": 300 } } ``` -------------------------------- ### Run Development Servers Source: https://github.com/falkordb/code-graph/blob/staging/_autodocs/INDEX.md Start the backend API with auto-reloading and the frontend development server. Access the application via the specified browser URL. ```bash # Terminal 1: Backend with auto-reload uv run uvicorn api.index:app --host 127.0.0.1 --port 5000 --reload ``` ```bash # Terminal 2: Frontend dev server (Vite) npm --prefix ./app run dev ``` ```bash # Browser: http://localhost:3000 ``` -------------------------------- ### Troubleshoot FalkorDB Lite Installation Source: https://github.com/falkordb/code-graph/blob/staging/_autodocs/README.md Command to install FalkorDB Lite, which may be required if encountering issues related to its absence. ```bash uv sync --extra light ``` -------------------------------- ### List Repositories cURL Example Source: https://github.com/falkordb/code-graph/blob/staging/_autodocs/endpoints.md Example cURL command to list all indexed repositories. This endpoint is accessible without authentication if `CODE_GRAPH_PUBLIC` is set to 1. ```bash curl http://localhost:5000/api/list_repos ``` -------------------------------- ### Start FalkorDB and CodeGraph with Docker Compose Source: https://github.com/falkordb/code-graph/blob/staging/README.md Use this command to start both FalkorDB and the CodeGraph application using the provided Docker Compose file. The compose file is pre-configured with `CODE_GRAPH_PUBLIC=1` for the app service. ```bash docker compose up --build ``` -------------------------------- ### Project Build and Management Commands Source: https://github.com/falkordb/code-graph/blob/staging/AGENTS.md Use these make commands for common project tasks like installation, building, running development servers, testing, and linting. ```bash make install # Install all deps (uv sync + npm install) make install-cli # Install cgraph CLI entry point make build-dev # Build frontend (dev mode) make build-prod # Build frontend (production) make run-dev # Build dev frontend + run API with reload make run-prod # Build prod frontend + run API make test # Run pytest suite make lint # Ruff + TypeScript type-check make lint-py # Ruff only make lint-fe # TypeScript type-check only make e2e # Run Playwright tests make clean # Remove build artifacts make docker-falkordb # Start FalkorDB container for testing make docker-stop # Stop test containers ``` -------------------------------- ### CLI Usage Examples Source: https://github.com/falkordb/code-graph/blob/staging/_autodocs/INDEX.md Illustrates common commands for interacting with the Code Graph via its command-line interface. ```APIDOC ## CLI Usage This section provides examples of using the `cgraph` command-line tool. ### Commands - `cgraph ensure-db`: Ensures the database is set up. - `cgraph index . --branch main --ignore .git --ignore node_modules`: Indexes the current directory. - `cgraph search "parse_"`: Searches for entities containing "parse_". - `cgraph neighbors 42 --rel CALLS`: Retrieves neighbors of node 42 with the relationship CALLS. - `cgraph paths 42 99`: Finds paths between node 42 and node 99. - `cgraph info`: Displays information about the code graph. ``` -------------------------------- ### Loading Configuration with python-dotenv Source: https://github.com/falkordb/code-graph/blob/staging/_autodocs/configuration.md Example of an .env file used with python-dotenv for loading configuration variables. Ensure this file is kept secure. ```bash # Database CODE_GRAPH_DB_BACKEND=lite FALKORDB_LITE_PATH=~/.cache/code-graph/falkordblite.rdb # Auth CODE_GRAPH_PUBLIC=1 # LLM MODEL_NAME=gemini/gemini-flash-lite-latest GEMINI_API_KEY=your-api-key # Server HOST=127.0.0.1 PORT=5000 ``` -------------------------------- ### Auto Complete cURL Example Source: https://github.com/falkordb/code-graph/blob/staging/_autodocs/endpoints.md Example cURL command for prefix-based entity search within a repository. Requires `Content-Type` header and a JSON request body. ```bash curl -X POST http://localhost:5000/api/auto_complete \ -H "Content-Type: application/json" \ -d '{"repo": "my-project", "prefix": "parse"}' ``` -------------------------------- ### Run Application with Make Source: https://github.com/falkordb/code-graph/blob/staging/CLAUDE.md Run the application in development mode with hot-reloading using `make run-dev`, which builds the dev frontend and starts the API. For production, use `make run-prod` after building the production frontend. ```bash make run-dev # Build dev frontend + run API with reload make run-prod # Build prod frontend + run API ``` -------------------------------- ### Fetch Graph Entities cURL Example Source: https://github.com/falkordb/code-graph/blob/staging/_autodocs/endpoints.md Example cURL command to fetch a sub-graph for a specific repository and branch. The `repo` parameter is required. ```bash curl "http://localhost:5000/api/graph_entities?repo=my-project&branch=main" ``` -------------------------------- ### Run Frontend Development Server Source: https://github.com/falkordb/code-graph/blob/staging/CLAUDE.md Start the Vite development server for the frontend. This command proxies API requests to port 5000 and provides hot-reloading for rapid development. ```bash npm --prefix ./app run dev # Vite dev server (port 3000, proxies /api to 5000) ``` -------------------------------- ### Manage Docker Containers with Make Source: https://github.com/falkordb/code-graph/blob/staging/CLAUDE.md Start the FalkorDB container for testing with `make docker-falkordb` and stop test containers with `make docker-stop`. ```bash make docker-falkordb # Start FalkorDB container for testing make docker-stop # Stop test containers ``` -------------------------------- ### Run FalkorDB with Docker Source: https://github.com/falkordb/code-graph/blob/staging/README.md Starts a local FalkorDB instance using Docker. Ensure port 6379 is available. ```bash docker run -p 6379:6379 -it --rm falkordb/falkordb ``` -------------------------------- ### Install FalkorDB Lite Dependency Source: https://github.com/falkordb/code-graph/blob/staging/_autodocs/api-reference-db.md Provides commands to install the FalkorDB Lite dependency using either uv or pip, enabling the use of FalkorDB Lite. ```bash # Install with lite extra pip install 'falkordb-code-graph[light]' # or uv sync --extra light ``` -------------------------------- ### Troubleshoot Module Not Found Source: https://github.com/falkordb/code-graph/blob/staging/_autodocs/README.md Command to install necessary dependencies, including test extras, to resolve 'MODULE_NOT_FOUND' errors. ```bash pip install falkordb-code-graph[test] ``` -------------------------------- ### Example Go Language Analyzer Implementation Source: https://github.com/falkordb/code-graph/blob/staging/_autodocs/api-reference-analyzers.md This pseudo-code demonstrates how to implement a new language analyzer for Go by subclassing AbstractAnalyzer. It shows the required methods for dependency checking, path resolution, and entity labeling. ```python from api.analyzers.analyzer import AbstractAnalyzer from tree_sitter import Language, Parser class GoAnalyzer(AbstractAnalyzer): def __init__(self): lang = Language("path/to/tree-sitter-go.so", "go") super().__init__(lang) def is_dependency(self, file_path: str) -> bool: return "vendor/" in file_path or "/go/src/" in file_path def resolve_path(self, file_path: str, path: Path) -> str: return str(Path(file_path).resolve()) def get_entity_label(self, node: Node) -> str: if node.type == "function_declaration": return "Function" elif node.type == "type_declaration": return "Class" return "Unknown" def get_entity_name(self, node: Node) -> str: # Extract name from node pass def add_dependencies(self, path: Path, files: list[Path]): # Add Go stdlib functions pass ``` -------------------------------- ### Configure FalkorDBLite Backend Source: https://github.com/falkordb/code-graph/blob/staging/README.md Sets up FalkorDBLite for local embedded use. Installs extra dependencies with 'uv' and exports environment variables to specify the backend and database path. ```bash uv sync --extra light export CODE_GRAPH_DB_BACKEND=lite export FALKORDB_LITE_PATH=~/.cache/code-graph/falkordblite.rdb ``` -------------------------------- ### Run Backend Development Server Source: https://github.com/falkordb/code-graph/blob/staging/CLAUDE.md Manually start the Uvicorn development server for the backend API. Ensure you are in the correct directory and have the necessary environment variables set. ```bash uv run uvicorn api.index:app --host 127.0.0.1 --port 5000 --reload ``` -------------------------------- ### Example of AbstractAnalyzer Base Class Implementation Source: https://github.com/falkordb/code-graph/blob/staging/_autodocs/SUMMARY.txt Provides a template for language implementation by extending the AbstractAnalyzer base class. This is for extension authors. ```python from falkordb.analyzers import AbstractAnalyzer class PythonAnalyzer(AbstractAnalyzer): def analyze(self, code: str, file_path: str) -> Dict[str, Any]: # Implement Python code analysis logic here # Parse code, extract AST, identify nodes and edges nodes = [] edges = [] # ... return {"nodes": nodes, "edges": edges} def get_language(self) -> str: return "python" ``` -------------------------------- ### Run Backend API and Frontend Dev Server Source: https://github.com/falkordb/code-graph/blob/staging/README.md Starts the backend API with auto-reload in one terminal and the Vite development server for the frontend in another. The frontend proxies API requests to the backend. ```bash # Terminal 1: backend API uv run uvicorn api.index:app --host 127.0.0.1 --port 5000 --reload # Terminal 2: Vite dev server cd app && npm run dev ``` -------------------------------- ### Install FalkorDB Code Graph Skill Source: https://github.com/falkordb/code-graph/blob/staging/skills/code-graph/references/management.md Use this command to add the FalkorDB Code Graph skill to your project. ```bash npx skills add FalkorDB/code-graph ``` -------------------------------- ### Python Class Hierarchy Example Source: https://github.com/falkordb/code-graph/blob/staging/tests/mcp/fixtures/sample_project/README.md Shows a simple Python class hierarchy. This is a textual representation and not executable code. ```text BaseRepo ├── UserRepo └── OrderRepo ``` -------------------------------- ### Get Neighbors cURL Example Source: https://github.com/falkordb/code-graph/blob/staging/_autodocs/endpoints.md Example cURL command to get neighboring nodes for a list of node IDs. Requires setting the `Content-Type` header and providing a JSON request body. ```bash curl -X POST http://localhost:5000/api/get_neighbors \ -H "Content-Type: application/json" \ -d '{"repo": "my-project", "node_ids": [1, 2]}' ``` -------------------------------- ### Copy Environment Template Source: https://github.com/falkordb/code-graph/blob/staging/README.md Copies the template file for environment variables. Adjust the '.env' file to match your local setup. ```bash cp .env.template .env ``` -------------------------------- ### Production (Remote FalkorDB, Public Read) Source: https://github.com/falkordb/code-graph/blob/staging/_autodocs/configuration.md Production setup with a remote FalkorDB, enabling public read access. Ensure sensitive credentials are managed securely. ```bash CODE_GRAPH_DB_BACKEND=falkordb FALKORDB_HOST=graph-db.example.com FALKORDB_PORT=6379 FALKORDB_USERNAME=production FALKORDB_PASSWORD=secure-password CODE_GRAPH_PUBLIC=1 SECRET_TOKEN=production-token-xyz MODEL_NAME=openai/gpt-4-turbo OPENAI_API_KEY=sk-... HOST=0.0.0.0 PORT=5000 ALLOWED_ANALYSIS_DIR=/var/code-projects ``` -------------------------------- ### Python Call Graph Example Source: https://github.com/falkordb/code-graph/blob/staging/tests/mcp/fixtures/sample_project/README.md Illustrates a typical Python call graph structure. This is a textual representation and not executable code. ```text entrypoint() -> service() -> {UserRepo,OrderRepo}.repo() -> db() ``` -------------------------------- ### Example cURL Request for an Endpoint Source: https://github.com/falkordb/code-graph/blob/staging/_autodocs/SUMMARY.txt Illustrates how to make an HTTP request to an endpoint using cURL. This is useful for API integrators. ```shell curl -X POST \ http://localhost:8080/api/v1/graph/project/analyze \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -d @request.json ``` -------------------------------- ### Fetch Repository Metadata Asynchronously Source: https://github.com/falkordb/code-graph/blob/staging/_autodocs/api-reference-utilities.md Example of how to use async_get_repo_info to fetch metadata in an async function. Ensure the async_get_repo_info function is imported. ```python from api.info import async_get_repo_info async def fetch_metadata(repo_name: str): info = await async_get_repo_info(repo_name) return info ``` -------------------------------- ### Index Repository Source: https://github.com/falkordb/code-graph/blob/staging/api/mcp/templates/claude_mcp_section.md Call this first when starting with a new repository or after significant changes. The project name is derived from the folder or URL. ```python index_repo(path_or_url=".") ``` -------------------------------- ### create_async_falkordb Source: https://github.com/falkordb/code-graph/blob/staging/_autodocs/api-reference-db.md Creates an asynchronous database client for non-blocking queries. It can return either a `falkordb.asyncio.FalkorDB` instance or a `redislite.async_falkordb_client.AsyncFalkorDB` instance if FalkorDBLite is selected and installed. ```APIDOC ## Function: `create_async_falkordb` ### Description Creates an asynchronous database client. Used by API endpoints for non-blocking queries. - **falkordb**: Uses `falkordb.asyncio.FalkorDB` (async client) - **lite**: Uses `redislite.async_falkordb_client.AsyncFalkorDB` with compatibility shim ### Returns Async FalkorDB or FalkorDBLite instance ### Throws RuntimeError if FalkorDBLite is selected but not installed ### Example ```python from api.db import create_async_falkordb async def query_graph(): db = create_async_falkordb() try: graphs = await db.list_graphs() g = db.select_graph("code:my-project:main") result = await g.query("MATCH (n:Function) RETURN count(n)") print(f"Functions: {result.result_set[0][0]}") finally: await db.aclose() # In async context: # await query_graph() ``` ``` -------------------------------- ### Query the Code Graph Source: https://github.com/falkordb/code-graph/blob/staging/_autodocs/INDEX.md Examples of querying the code graph for relationships and paths. Includes finding neighbors, pathfinding, and prefix searches. ```python # Get all outgoing edges from a function neighbors = g.get_neighbors([42], rel="CALLS", lbl="Function") # Find call chains paths = g.find_paths(src=42, dest=99, limit=10) # Prefix search results = g.prefix_search("parse_", limit=20) ``` -------------------------------- ### Project Initialization and Analysis Source: https://github.com/falkordb/code-graph/blob/staging/_autodocs/api-reference-project.md Demonstrates how to initialize a Project object for a local folder or clone a Git repository, and then analyze its source code and Git history. ```APIDOC ## Project Initialization and Analysis ### Description This section shows how to create a `Project` instance, either from a local directory or by cloning a Git repository, and subsequently analyze its source code and Git history. ### Usage **Option 1: Analyze local folder** ```python from api.project import Project from pathlib import Path project = Project( name="my-project", path=Path("/home/user/my-project"), url="https://github.com/user/my-project" ) graph = project.analyze_sources(ignore=[".git", "node_modules"]) git_graph = project.process_git_history() ``` **Option 2: Clone and analyze GitHub repo** ```python project = Project.from_git_repository( "https://github.com/user/my-project", branch="main" ) graph = project.analyze_sources() git_graph = project.process_git_history() ``` ### Methods - **`Project(name: str, path: Path, url: Optional[str] = None)`**: Constructor for initializing a Project from a local path. - **`Project.from_git_repository(url: str, branch: str = "main")`**: Class method to clone a Git repository and initialize a Project. - **`project.analyze_sources(ignore: Optional[List[str]] = None)`**: Analyzes the source code of the project. Returns a `Graph` object. - **`project.process_git_history()`**: Processes the Git commit history of the project. Returns a `GitGraph` object. ``` -------------------------------- ### CLI Usage for Database and Indexing Source: https://github.com/falkordb/code-graph/blob/staging/_autodocs/README.md These bash commands show how to ensure the database is set up and how to index a local project using the CLI, specifying branches and directories to ignore. ```bash cgraph ensure-db cgraph index . --branch main --ignore .git --ignore node_modules ``` -------------------------------- ### Initialize Agent Guidance Source: https://github.com/falkordb/code-graph/blob/staging/CLAUDE.md Use `cgraph init-agent` to write CLAUDE.md and .cursorrules into a repository. Use the `--force` flag to overwrite existing files. ```bash cgraph init-agent # writes CLAUDE.md + .cursorrules ``` ```bash cgraph init-agent --force # overwrite existing files ``` -------------------------------- ### Clone and Index a GitHub Repository with cgraph Source: https://github.com/falkordb/code-graph/blob/staging/_autodocs/cli-reference.md Ensures the database is ready, then clones and indexes a GitHub repository. Ignores specified directories and performs a search for functions starting with 'parse_'. ```bash cgraph ensure-db cgraph index-repo https://github.com/user/my-project \ --ignore .git \ --ignore node_modules cgraph search "parse_" ``` -------------------------------- ### Create Async FalkorDB Client Source: https://github.com/falkordb/code-graph/blob/staging/_autodocs/api-reference-db.md Creates an asynchronous FalkorDB or FalkorDBLite client. Use this for non-blocking graph queries. It may throw a RuntimeError if FalkorDBLite is selected but not installed. ```python from api.db import create_async_falkordb async def query_graph(): db = create_async_falkordb() try: graphs = await db.list_graphs() g = db.select_graph("code:my-project:main") result = await g.query("MATCH (n:Function) RETURN count(n)") print(f"Functions: {result.result_set[0][0]}") finally: await db.aclose() # In async context: # await query_graph() ``` -------------------------------- ### Build Frontend with Make Source: https://github.com/falkordb/code-graph/blob/staging/CLAUDE.md Build the frontend application for development or production using `make build-dev` or `make build-prod` respectively. These commands compile frontend assets. ```bash make build-dev # Build frontend (dev mode) make build-prod # Build frontend (production) ``` -------------------------------- ### Create and List Graphs (Sync) Source: https://github.com/falkordb/code-graph/blob/staging/_autodocs/api-reference-db.md Demonstrates how to explicitly create a FalkorDB connection and list existing graphs. Typically, the Graph class handles connection management internally. ```python from api.graph import Graph from api.db import create_falkordb # Explicitly create/manage database connection db = create_falkordb() graphs = db.list_graphs() # But typically, Graph() handles this internally g = Graph("my-project", branch="main") stats = g.stats() ``` -------------------------------- ### Initialize Project Instance Source: https://github.com/falkordb/code-graph/blob/staging/_autodocs/api-reference-project.md Initializes a Project instance with project details. Automatically detects the current branch if not provided. Creates or opens the associated Graph. ```python from api.project import Project from pathlib import Path project = Project( name="my-project", path=Path("/home/user/my-project"), url="https://github.com/user/my-project", branch="main" ) ``` -------------------------------- ### Code Graph CLI Commands Source: https://github.com/falkordb/code-graph/blob/staging/CLAUDE.md Common commands for managing and interacting with the Code Graph database, including starting the DB, indexing files and repositories, searching, and retrieving information. ```bash cgraph ensure-db ``` ```bash cgraph index . --ignore node_modules ``` ```bash cgraph index-repo ``` ```bash cgraph list ``` ```bash cgraph search [--repo ] ``` ```bash cgraph neighbors ... [--repo ] [--rel ] [--label