MCPcopy Index your code
hub / github.com/douglance/devsql

github.com/douglance/devsql @v0.3.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.3.0 ↗ · + Follow
500 symbols 1,098 edges 77 files 97 documented · 19%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

DevSQL

Unified SQL interface across AI coding history, Git repositories, and source code.

DevSQL loads data from Claude Code, Codex CLI, Git, and your source tree into an in-memory SQLite database so you can join, filter, and aggregate across all of them with standard SQL.

Overview

~/.claude/    ─┐
~/.codex/     ─┤
.git/         ─┼──▶  SQLite (in-memory)  ──▶  SQL queries / JSON / CSV
src/**/*      ─┘

Three standalone tools, one unified interface:

Tool Data Source
ccql Claude Code + Codex CLI data (~/.claude/, ~/.codex/)
vcsql Git repositories (commits, branches, diffs)
devsql All of the above, plus source code analysis

DevSQL auto-detects which tables your query references and only loads the data it needs.

Installation

Homebrew

brew install douglance/tap/devsql

Claude Code Plugin

/plugin marketplace add douglance/devsql
/plugin install devsql@devsql

The plugin auto-installs the binary on first session start.

Direct Download

Prebuilt binaries for macOS and Linux are available from GitHub Releases.

From Source

git clone https://github.com/douglance/devsql.git
cd devsql && cargo install --path crates/devsql

To enable tree-sitter-based AST analysis (richer symbol extraction and import parsing):

cargo install --path crates/devsql --features tree-sitter-ast

Usage

SQL Queries

devsql "<SQL>"                # Default table output
devsql -f json "<SQL>"        # JSON output
devsql -f csv "<SQL>"         # CSV output

Commands

Structured commands that return JSON, designed for use by AI agents and scripts:

Command Description
devsql search <query> Find symbols by name across the codebase
devsql context <file> File metadata and symbols for a given path
devsql history <file> Git commit history for a specific file
devsql diff <base> <head> Compare two Git refs with file and symbol-level stats
devsql impact <file> Analyze exports and find potential dependents

Common options: --repo / -r (default .), --data-dir / -d (default ~/.claude).

Tables

AI History

Table Source Description
history ~/.claude/history.jsonl Claude Code prompts (timestamp, display, project)
transcripts ~/.claude/projects/<slug>/**/*.jsonl (+ legacy ~/.claude/transcripts/*.jsonl) Full conversations incl. subagents (type, content, tool_name, session_id, _project, _agent_id, timestamp, model, usage_* token columns)
sessions Same files as transcripts One row per session: title, cwd, git_branch, first/last_timestamp, message counts, subagent_count, total_*_tokens, pr_url, pr_number
todos ~/.claude/todos/*.json Task items (content, status)
jhistory ~/.codex/history.jsonl Codex CLI prompts (session_id, text, display, timestamp)
codex_history Alias for jhistory

Git

Table Description
commits id, message, summary, author_name, authored_at, short_id
branches name, is_head, commit_id
diffs Commit-level stats: commit_id, files_changed, insertions, deletions
diff_files Per-file stats: commit_id, path, status (A/D/M/R/C), insertions, deletions

Source Code

Table Description
source_files File inventory: path, name, extension, directory, size_bytes, line_count, modified_at, language
source_lines Line content: file_path, line_number, content, is_blank
symbols Definitions: file_path, name, kind, line_start, line_end, signature, visibility, parameters, return_type, language
imports* Import statements: file_path, line_number, module, name, alias, kind, is_default, is_wildcard
ast_nodes* Raw AST nodes

* Requires the tree-sitter-ast feature for full extraction. Without it, symbols falls back to regex-based extraction (Rust, TypeScript, JavaScript, Python, Go) and imports/ast_nodes are empty.

Examples

Join prompts with commits

SELECT
  date(c.authored_at) as day,
  COUNT(DISTINCT h.timestamp) as prompts,
  COUNT(DISTINCT c.id) as commits
FROM commits c
LEFT JOIN history h
  ON date(c.authored_at) = date(datetime(h.timestamp/1000, 'unixepoch'))
GROUP BY day
ORDER BY day DESC
LIMIT 14;

Find productive prompts

SELECT h.display as prompt, COUNT(c.id) as commits_after
FROM history h
JOIN commits c ON date(datetime(h.timestamp/1000, 'unixepoch')) = date(c.authored_at)
GROUP BY h.display
HAVING commits_after > 0
ORDER BY commits_after DESC
LIMIT 20;

Codebase overview by language

SELECT language, COUNT(*) as files, SUM(line_count) as total_lines
FROM source_files
GROUP BY language
ORDER BY total_lines DESC;

Hottest files (most commits + most symbols)

SELECT df.path,
  COUNT(DISTINCT df.commit_id) as commits,
  SUM(df.insertions) as lines_added,
  (SELECT COUNT(*) FROM symbols s WHERE s.file_path = df.path) as symbols
FROM diff_files df
GROUP BY df.path
ORDER BY commits DESC
LIMIT 10;

Search symbols

devsql search "parse"
devsql search "Error" --kind struct

Semantic diff between refs

devsql diff main~5 HEAD

File context and impact

devsql context src/engine.rs
devsql impact src/lib.rs
devsql history src/engine.rs

Notes

  • history.timestamp is in epoch milliseconds. Use datetime(timestamp/1000, 'unixepoch') to convert.
  • A custom DATE() function normalizes epoch ms, epoch seconds, and ISO strings.
  • Tables are loaded lazily — only those referenced in your query are populated.
  • The symbols table extracts functions, structs, enums, traits, types, classes, interfaces, and more depending on language.

License

MIT

Extension points exported contracts — how you extend this code

Provider (Interface)
(no doc) [17 implementers]
crates/vcsql/src/providers/mod.rs

Core symbols most depended-on inside this repo

path
called by 67
crates/vcsql/src/git/repository.rs
execute
called by 29
crates/ccql/src/sql/mod.rs
execute
called by 25
crates/vcsql/src/sql/engine.rs
is_empty
called by 23
crates/vcsql/src/sql/engine.rs
writeln
called by 21
crates/ccql/src/cli/output.rs
write
called by 16
crates/ccql/src/sql/composite_storage.rs
write_json
called by 16
crates/ccql/src/cli/output.rs
is_virtual_table
called by 15
crates/ccql/src/sql/composite_storage.rs

Shape

Method 203
Function 198
Class 86
Enum 12
Interface 1

Languages

Rust98%
TypeScript2%

Modules by API surface

crates/ccql/src/sql/composite_storage.rs61 symbols
crates/devsql/src/engine.rs30 symbols
crates/devsql/src/providers/symbols.rs26 symbols
crates/ccql/src/datasources/transcript.rs20 symbols
crates/ccql/src/sql/safety.rs19 symbols
crates/devsql/src/providers/mod.rs14 symbols
crates/devsql/src/providers/imports.rs14 symbols
crates/ccql/src/config/mod.rs14 symbols
crates/ccql/src/sql/mod.rs12 symbols
crates/ccql/src/models/transcript.rs12 symbols
crates/vcsql/src/sql/engine.rs11 symbols
crates/vcsql/src/git/repository.rs11 symbols

For agents

$ claude mcp add devsql \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact