Skip to content

Feature Request: Configurable .codegraph/ data directory location #304

@Roalkege

Description

@Roalkege

Feature Request: Configurable .codegraph/ data directory location

Summary

Currently, CodeGraph always creates its .codegraph/ directory (SQLite database, config, etc.) inside the project root. There is no way to store this data elsewhere.

Problem

Having .codegraph/ live in the project root has a few downsides:

  • It pollutes the project directory with tool-generated artifacts
  • It requires adding .codegraph/ to .gitignore in every project
  • Some setups (monorepos, read-only mounts, strict repo hygiene policies) make writing to the project root undesirable

Proposed Solution

Add a configuration option to specify a custom data directory, for example:

  • A --data-dir <path> flag for CLI commands (init, index, sync, serve, etc.)
  • Or an environment variable like CODEGRAPH_DATA_DIR
  • Or a global config in ~/.config/codegraph/ that maps project paths to storage locations

The MCP server's directory-walking logic (currently looking for .codegraph/ up the directory tree) could fall back to a user-defined location if no .codegraph/ is found in the project tree.

Workaround

Currently the only clean workaround is a symlink:

mkdir -p ~/.local/share/codegraph/my-project
ln -s ~/.local/share/codegraph/my-project /path/to/project/.codegraph

This works but is manual and not portable across machines.

Use Case

Any developer who wants to keep their project directories clean of generated/local-only artifacts, similar to how tools like .gradle, .yarn/cache, or VS Code's jsconfig allow overriding cache/data locations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions