Agent skill

Codebase Query

by meain in meain/dotfiles

Query and analyze codebases semantically using codebase-memory-mcp graph database.

MITAuto-check passedDevelopment

Install Codebase Query

skills CLI
$ npx skills add meain/dotfiles --skill codebase-query -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install meain/dotfiles codebase-query --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/meain/dotfiles.git skills-src && mkdir -p .claude/skills && cp -r skills-src/agents/.agents/skills/codebase-query .claude/skills/codebase-query && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
codebase-query
GitHub stars
285
Token cost
~2.5k tokens
SKILL.md length
739 words
Files
3 (incl. references)
Skills in repo
36
Repo updated
First seen
Licence
MIT

At a glance

Query and analyze codebases semantically using codebase-memory-mcp graph database.

  • Works in 4 steps: Search & Discovery → Call Graph Analysis → Complexity & Quality → …
  • Explore code structure
  • SKILL.md covers Triggers and Instructions
  • Calls jq

What it does

Codebase Query is an agent skill from meain/dotfiles. Query and analyze codebases semantically using codebase-memory-mcp graph database. Use to explore code structure, complexity, dependencies, call graphs, and architecture. Triggers: /codebase-query, /cbm, /code-graph, "show me high complexity functions", "what calls X", "find implementations of", "map service entry points", "analyze code complexity", "find technical debt", "what implements this interface"

Its SKILL.md is about 2.5k tokens, which your agent loads only when the skill is triggered. The skill folder holds 3 other files, including reference files (for example `references/cookbook.md` and `references/integrations.md`).

It sits in Development, covering Codebase onboarding and Technical debt. It works with Model Context Protocol. The repository describes itself as: If there is a shell, there is a way! The licence is MIT.

When your agent uses it

  • Explore code structure
  • Tasks that involve Codebase onboarding
  • Tasks that involve Technical debt

Example prompts

  • “show me high complexity functions”
  • “what calls X”
  • “find implementations of”
  • “/codebase-query”

Workflow steps

4 steps, taken from the first numbered list in SKILL.md.

  1. Search & Discovery
  2. Call Graph Analysis
  3. Complexity & Quality
  4. Architecture Insights

What it can do on your machine

Read from SKILL.md and the folder at commit f469fb6. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • jq

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Codebase Query loads about 2.5k tokens when it runs, and up to ~7.6k if it reads all its reference files. Until then it costs about 106 tokens; SKILL.md has 739 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~106
When it runs · the whole SKILL.md, loaded when a task matches
~2.5k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~7.6k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from meain/dotfiles at commit f469fb6, republished under its MIT licence (© meain). 739 words, ~2,455 tokens.

Download SKILL.mdSave it as .claude/skills/codebase-query/SKILL.md (or your agent's skills folder). This skill also uses 2 other files; get the full folder from GitHub.
name
codebase-query
description
Query and analyze codebases semantically using codebase-memory-mcp graph database. Use to explore code structure, complexity, dependencies, call graphs, and architecture. Triggers: /codebase-query, /cbm, /code-graph, "show me high complexity functions", "what calls X", "find implementations of", "map service entry points", "analyze code complexity", "find technical debt", "what implements this interface"
aliases
cbm, code-graph
user_invocable
true

codebase-query

Query and analyze codebases using codebase-memory-mcp semantic graph.

Triggers

  • /codebase-query, /cbm, /code-graph
  • "query the codebase graph"
  • "find functions that call X"
  • "show me high complexity functions"
  • "what implements this interface"
  • "analyze code complexity"
  • "map the architecture"
  • "find technical debt"

Instructions

You are a codebase graph query assistant. Use codebase-memory-mcp to answer questions about code structure, complexity, dependencies, and architecture.

Core Capabilities
  1. Search & Discovery

    • Find functions/methods, interfaces, types by name pattern
    • Get function implementations and signatures
    • Discover entry points and exported APIs
    • Grep-like code search via search_code
  2. Call Graph Analysis

    • Trace callers and callees
    • Map execution flows
    • Find hot paths and bottlenecks
  3. Complexity & Quality

    • Identify high-complexity functions
    • Find functions with many parameters
    • Detect unguarded recursion
    • Locate potential code smells
  4. Architecture Insights

    • High-level overview via get_architecture
    • Schema discovery via get_graph_schema
    • Map service boundaries
    • Find cross-service dependencies
    • Discover interface implementations
    • Track HTTP endpoints and async patterns
Query Patterns

Note: In Claude Code, codebase-memory-mcp MCP tools are available natively. Prefer calling them directly over CLI. CLI examples use 2>&1 | grep -v "^level=" to suppress logs.

For Quick Overview (unfamiliar codebase)

Use get_architecture and get_graph_schema:

bash
codebase-memory-mcp cli get_architecture '{"project": "...", "aspects": ["entry_points"]}' 2>&1 | grep -v "^level="
codebase-memory-mcp cli get_graph_schema '{"project": "..."}' 2>&1 | grep -v "^level=" | jq '.node_labels[] | {label: .label, count: .count}'
For Simple Lookups

Use search_graph or trace_path:

bash
codebase-memory-mcp cli search_graph '{"project": "...", "name_pattern": ".*Router.*", "label": "Function"}' 2>&1 | grep -v "^level="
codebase-memory-mcp cli trace_path '{"project": "...", "function_name": "CreateEvent", "direction": "both", "max_depth": 2}' 2>&1 | grep -v "^level="

Use search_code when looking for string literals or patterns:

bash
codebase-memory-mcp cli search_code '{"project": "...", "pattern": "GetOrgRegion", "file_pattern": "*.go", "limit": 10}' 2>&1 | grep -v "^level="
For Complex Analysis

Use query_graph with Cypher:

bash
codebase-memory-mcp cli query_graph '{
  "project": "...",
  "query": "MATCH (f:Function) WHERE f.complexity > 15 AND f.is_test = false RETURN f.name, f.complexity, f.file_path ORDER BY f.complexity DESC LIMIT 10"
}' 2>&1 | grep -v "^level="
Project Name Detection

When in a repository:

  1. First try list_projects to find the indexed project name
  2. Project names follow pattern: Users-meain-dev-folder-repo (path with slashes replaced by dashes)
  3. For /Users/acme/dev/myapp/backend → Users-acme-dev-myapp-backend
  4. On an unfamiliar project, follow with get_graph_schema to discover available node types and properties
Common Queries

Find high complexity:

cypher
MATCH (f:Function) 
WHERE f.complexity > 15 AND f.is_test = false 
RETURN f.name, f.complexity, f.file_path 
ORDER BY f.complexity DESC LIMIT 10

Find interface implementations:

cypher
MATCH (s)-[:IMPLEMENTS]->(i:Interface {name: 'InterfaceName'}) 
RETURN s.name, s.file_path

Find functions with many parameters:

cypher
MATCH (f:Function) 
WHERE f.param_count > 7 AND f.is_test = false 
RETURN f.name, f.param_count, f.file_path 
ORDER BY f.param_count DESC LIMIT 10

Find entry points:

cypher
MATCH (f:Function) 
WHERE f.is_entry_point = true 
RETURN f.name, f.file_path

Find hot paths (most-called functions):

cypher
MATCH ()-[:CALLS]->(f:Function)
WHERE f.is_test = false
WITH f, count(*) as call_count
RETURN f.name, call_count, f.file_path
ORDER BY call_count DESC LIMIT 15

Find recursive functions:

cypher
MATCH (f:Function) 
WHERE f.recursive = true 
RETURN f.name, f.file_path

Find HTTP endpoints:

cypher
MATCH (f:Function)-[h:HTTP_CALLS]->(target) 
RETURN f.name, h.url_path, f.file_path 
LIMIT 15

Find external dependencies:

cypher
MATCH (p:Package) 
WHERE p.external = true 
RETURN p.name 
ORDER BY p.name

Find similar functions (duplication candidates):

cypher
MATCH (f1:Function)-[s:SIMILAR_TO]->(f2:Function)
WHERE s.same_file = false AND s.jaccard > 0.7
RETURN f1.name, f2.name, s.jaccard, f1.file_path, f2.file_path
LIMIT 10
Cypher Query Tips

Boolean comparisons:

  • ✓ Use f.is_test = false
  • ✗ Don't use NOT f.is_test (syntax error)

String operations:

  • f.file_path STARTS WITH 'services/'
  • f.file_path ENDS WITH '_test.go'
  • f.file_path CONTAINS 'organchor'
  • toLower(f.name) CONTAINS 'anchor'

Aggregation:

cypher
MATCH (f:Function)-[:CALLS]->(target)
WITH f, count(*) as call_count
RETURN f.name, call_count
ORDER BY call_count DESC

Limitations:

  • Variable-length paths (*1..3) not supported
  • Some boolean operators cause errors
  • Keep queries focused with WHERE and LIMIT
Available Properties

Function / Method nodes (both types carry the same properties):

  • name, qualified_name, file_path, signature
  • complexity, cognitive (complexity metrics)
  • param_count, loop_count, loop_depth
  • is_exported, is_test, is_entry_point
  • recursive, unguarded_recursion
  • lines, docstring

Relationships:

  • :CALLS - function calls
  • :IMPLEMENTS - interface implementation
  • :IMPORTS - module imports
  • :USAGE - symbol usage (largest edge set)
  • :TESTS - test relationships (may be sparse)
  • :SIMILAR_TO - code similarity (has .jaccard and .same_file properties)
  • :HTTP_CALLS - HTTP endpoints (has .url_path property)
  • :ASYNC_CALLS - async patterns (has .broker property)
  • :CONFIGURES - config access (has .config_key property)
Output Processing

Filter stderr and parse JSON:

bash
codebase-memory-mcp cli query_graph '...' 2>&1 | grep -v "^level=" | jq .
# For user-friendly tabular output:
| jq -r '.rows[] | "\(.[0]): \(.[1]) (\(.[2]))"'
Show full SKILL.md (312 more words)Show less
Workflow
  1. Understand the question - what is the user asking?
  2. Check if project is indexed - list_projects
  3. Explore schema if unfamiliar - get_graph_schema to see available node types and counts
  4. Choose the right tool:
    • High-level overview → get_architecture
    • Simple name search → search_graph
    • Call chains → trace_path
    • Complex queries → query_graph
    • Code snippets → get_code_snippet
    • Pattern/string search → search_code
  5. Execute the query with proper filtering
  6. Format and explain results with context
When to Use vs. Grep/Ripgrep

Use codebase-memory-mcp when:

  • Finding call relationships
  • Analyzing complexity
  • Discovering interfaces/implementations
  • Understanding architecture
  • Identifying technical debt

Use search_code (CBM grep-like) when:

  • Pattern search but want to stay in the same tool
  • Searching within already-indexed scope

Use grep/ripgrep when:

  • Searching for string literals in comments/docs
  • Patterns outside indexed scope
  • Fastest possible raw text search

Combine both:

  • CBM finds high-complexity function names → rg locates their usage in docs/config
Example Interactions

Q: "Show me the most complex functions in the earn service"

A: Query with:

cypher
MATCH (f:Function) 
WHERE f.file_path STARTS WITH 'services/earn/' AND f.is_test = false 
RETURN f.name, f.complexity, f.cognitive, f.file_path 
ORDER BY f.complexity DESC LIMIT 10

Q: "What implements the EventRouter interface?"

A: Query with:

cypher
MATCH (s)-[:IMPLEMENTS]->(i:Interface {name: 'EventRouter'}) 
RETURN s.name, s.file_path

Q: "Find all functions that call GetOrgRegion"

A: Use trace_path:

bash
codebase-memory-mcp cli trace_path '{
  "project": "...",
  "function_name": "GetOrgRegion",
  "direction": "callers",
  "max_depth": 2
}'
Integration with Other Skills
  • Combine with /refactorability to validate complexity findings
  • Use before /create-commit to understand change impact
  • Reference in /backlog for technical debt tasks
  • Export to /vault for documentation
Error Handling
  • If project not found: run list_projects first
  • If data seems stale: run detect_changes then index_repository to reindex
  • If query syntax error: simplify, avoid NOT, use = false
  • If timeout: add more WHERE filters and reduce LIMIT
  • If empty results: check get_graph_schema for available properties and edge counts
  • If Function query returns nothing: try Method (methods have nearly as many nodes as functions in Go repos)
References

See references/ for:

  • cookbook.md — 50+ query recipes by category
  • integrations.md — integration patterns with rg, jj, lint, gh, fzf, emacs

When user invokes this skill, identify what they want to analyze, construct the appropriate query, execute it, and present results with actionable insights.

© meain, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 2 other files (references) in agents/.agents/skills/codebase-query of meain/dotfiles.

  • SKILL.md
  • references/cookbook.md
  • references/integrations.md

Open the folder on GitHubat commit f469fb6

Compare with similar skills

Codebase Query next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Codebase Query compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Codebase Query this skillmeain/dotfiles285—~2.5kAutomated safety check: PassMIT
GitDiagram Repository Overviewahmedkhaleel2004/gitdiagram18k—~427Automated safety check: PassMIT
Explore Codebase with Graphtirth8205/code-review-graph32k1 repos~335Automated safety check: PassMIT
Grepaiyoanbernabeu/grepai1.9k—~1.1kAutomated safety check: PassMIT
Octocode Code Researchbgauryy/octocode946—~1.5kAutomated safety check: PassMIT
Releaseyoanbernabeu/grepai1.9k—~918Automated safety check: PassMIT

Similar skills

  • GitDiagram Repository Overview

    ahmedkhaleel2004/gitdiagram

    Explains the architecture of a public GitHub repository through GitDiagram: how the code is organized, the main components with paths, and a Mermaid diagram.

    18k GitHub stars~427 tokensUpdated today
    DevelopmentAuto-check passed
  • Explore Codebase with Graph

    tirth8205/code-review-graph

    Navigates a codebase through the code-review-graph MCP tools: architecture overview, symbol search, caller and callee tracing, flows and oversized functions.

    32k GitHub starsUsed in 1 repo~335 tokens
    DevelopmentAuto-check passed
  • Grepai

    yoanbernabeu/grepai

    Semantic code search and call-graph tracing. An agent skill from yoanbernabeu/grepai.

    1.9k GitHub stars~1.1k tokensUpdated 16 days ago
    DevelopmentAuto-check passed
  • Octocode Code Research

    bgauryy/octocode

    Researches code with evidence: traces callers, imports and cross-repo links, diagnoses failures and reports findings with exact file and line references and a confidence label.

    946 GitHub stars~1.5k tokensUpdated 4 days ago
    DevelopmentAuto-check passed
  • Release

    yoanbernabeu/grepai

    Create a new release for grepai. An agent skill from yoanbernabeu/grepai.

    1.9k GitHub stars~918 tokensUpdated 16 days ago
    DevelopmentAuto-check passed
  • Replaces grep, cat, find and ls with the tilth CLI, which returns AST-aware outlines, definitions, usages and callers across many languages in one call.

    352 GitHub stars~1.1k tokensUpdated 10 days ago
    DevelopmentAuto-check passed

More from meain/dotfiles

All 36 skills in this repo
  • Recall

    meain/dotfiles

    Search past Claude Code and Codex sessions. An agent skill from meain/dotfiles.

    285 GitHub starsUsed in 1 repo~684 tokens
    Auto-check passed
  • Grill With Docs

    meain/dotfiles

    Grilling session that challenges your plan against the existing domain model, sharpens terminology, and updates documentation (CONTEXT.md, ADRs) inline as decisions crystallise.

    285 GitHub starsUsed in 21 repos~875 tokens
    Auto-check passed
  • Backlog

    meain/dotfiles

    Daily backlog management — full planning review OR add a single entry from a URL.

    285 GitHub stars~3k tokensUpdated 1 mo ago
    Auto-check passed
  • Concern Review

    meain/dotfiles

    Generate an interactive local HTML review page for a large PR or diff, grouping the changed files by logical concern (not just by file) so a reviewer can go through one theme at a time instead of a…

    285 GitHub stars~2.2k tokensUpdated 1 mo ago
    Auto-check passed
  • My Weekly Report

    meain/dotfiles

    Generate a concise weekly status update in team format. An agent skill from meain/dotfiles.

    285 GitHub stars~2.5k tokensUpdated 1 mo ago
    Auto-check passed
  • Web Search

    meain/dotfiles

    Search the web using lynx and DuckDuckGo. An agent skill from meain/dotfiles.

    285 GitHub stars~830 tokensUpdated 1 mo ago
    Auto-check passed

Categories

Questions about Codebase Query

What does Codebase Query do?

Query and analyze codebases semantically using codebase-memory-mcp graph database. Codebase Query is an agent skill from meain/dotfiles. Query and analyze codebases semantically using codebase-memory-mcp graph database.

When should I use Codebase Query?

Codebase Query fits situations like: explore code structure; tasks that involve Codebase onboarding; tasks that involve Technical debt.

How do I install Codebase Query in Claude Code?

Run `npx skills add meain/dotfiles --skill codebase-query -a claude-code`. Or copy the skill folder (agents/.agents/skills/codebase-query in meain/dotfiles) into .claude/skills/codebase-query in your project. Claude Code loads it when a task matches its description.

How do I install Codebase Query in Codex?

Run `npx skills add meain/dotfiles --skill codebase-query -a codex`. Or copy the skill folder (agents/.agents/skills/codebase-query in meain/dotfiles) into .agents/skills/codebase-query in your project. Codex loads it when a task matches its description.

Can I use Codebase Query in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add meain/dotfiles --skill codebase-query -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/codebase-query, .gemini/skills/codebase-query, .github/skills/codebase-query and .opencode/skills/codebase-query in your project.

What does Codebase Query need to run?

Going by SKILL.md and its folder, Codebase Query needs the command-line tools its instructions call (jq).

Does Codebase Query access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Codebase Query safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Codebase Query use?

Codebase Query is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Codebase Query use?

About 2.5k tokens (SKILL.md is roughly 9.8k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 5.1k tokens, read only when the agent opens those files.

What are the alternatives to Codebase Query?

Skills that share tags, products or a category with Codebase Query: GitDiagram Repository Overview (ahmedkhaleel2004/gitdiagram, 18k stars), Explore Codebase with Graph (tirth8205/code-review-graph, 32k stars), Grepai (yoanbernabeu/grepai, 1.9k stars) and Octocode Code Research (bgauryy/octocode, 946 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Codebase Query?

meain (a GitHub user) maintains it in meain/dotfiles, which has 285 GitHub stars. The repository holds 36 skills in this directory. The repository was last updated on September 5, 2026.

Source: meain/dotfiles on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.