amplihack query-code¶
Full CLI reference for amplihack query-code — query the native
code-graph populated by index-code or index-scip.
Contents¶
- Synopsis
- Global options
- Subcommands
- stats
- context
- files
- functions
- classes
- search
- callers
- callees
- JSON output
- Exit codes
- Related commands
Synopsis¶
Global options¶
| Option | Default | Description |
|---|---|---|
--db-path <PATH> |
<cwd>/.amplihack/graph_db |
Path to the code-graph database directory. --kuzu-path remains as a backward-compatible alias. |
--json |
false | Emit output as JSON instead of human-readable text. |
--limit <N> |
50 | Maximum number of rows returned by list subcommands. |
Subcommands¶
stats¶
Print aggregate counts for the entire code-graph, including any native memory↔code relationships already linked in the same project-local LadybugDB.
Human-readable output:
Code Graph Statistics:
Files: 89
Classes: 24
Functions: 412
Memory→File links: 7
Memory→Function links: 3
JSON output (--json):
{
"files": 89,
"classes": 24,
"functions": 412,
"memory_file_links": 7,
"memory_function_links": 3
}
context¶
Show the linked code context for a memory ID. This uses the native memory→file and memory→function relationships stored in the same code-graph DB.
| Argument | Description |
|---|---|
<MEMORY_ID> |
Exact memory identifier to inspect. |
Human-readable output:
Code context for memory 'mem-query':
Files:
- src/example/module.py [python] (10 bytes)
Functions:
- helper ::
Classes: none
JSON output (--json):
{
"memory_id": "mem-query",
"files": [
{
"type": "file",
"path": "src/example/module.py",
"language": "python",
"size_bytes": 10
}
],
"functions": [
{
"type": "function",
"name": "helper",
"signature": "",
"docstring": "",
"complexity": 0
}
],
"classes": []
}
If the memory ID does not exist, the command still exits 0 and returns empty
files, functions, and classes arrays.
files¶
List all CodeFile nodes in the graph, optionally filtered by a path
substring.
| Option | Description |
|---|---|
--pattern <SUBSTRING> |
Case-sensitive substring filter applied to the stored file path. |
Example — all files:
amplihack query-code files
# src/main.rs
# src/commands/fleet.rs
# src/commands/memory/code_graph.rs
# ...
Example — filter by path fragment:
amplihack query-code files --pattern commands/memory
# src/commands/memory/code_graph.rs
# src/commands/memory/scip_indexing.rs
# src/commands/memory/mod.rs
JSON output (--json):
[
{ "file_path": "src/commands/memory/code_graph.rs", "language": "rust", "size_bytes": 28160 },
{ "file_path": "src/commands/memory/scip_indexing.rs", "language": "rust", "size_bytes": 16384 }
]
functions¶
List CodeFunction nodes, optionally filtered by the file that defines them.
| Option | Description |
|---|---|
--file <SUBSTRING> |
Case-sensitive substring filter applied to the function's source file path. |
Example:
amplihack query-code functions --file code_graph
# import_blarify_json (src/commands/memory/code_graph.rs:236)
# import_scip_file (src/commands/memory/code_graph.rs:200)
# summarize_code_graph (src/commands/memory/code_graph.rs:315)
# ...
JSON output (--json):
[
{
"function_name": "import_blarify_json",
"fully_qualified_name": "amplihack_cli::commands::memory::code_graph::import_blarify_json",
"file_path": "src/commands/memory/code_graph.rs",
"line_number": 236,
"signature": "(input_path: &Path, db_path: Option<&Path>) -> Result<CodeGraphImportCounts>",
"is_async": false,
"cyclomatic_complexity": 4
}
]
classes¶
List CodeClass nodes, optionally filtered by source file.
| Option | Description |
|---|---|
--file <SUBSTRING> |
Case-sensitive substring filter applied to the class's source file path. |
Example:
amplihack query-code classes --file fleet
# FleetState (src/commands/fleet.rs:2011)
# FleetAdmiral (src/commands/fleet.rs:2189)
# FleetTuiUiState (src/commands/fleet.rs:1829)
search¶
Search for any symbol (file, function, or class) whose name contains the given substring. Searches across all three node types in one pass.
| Argument | Description |
|---|---|
<NAME> |
Substring to search for (case-sensitive). |
Example:
amplihack query-code search import_scip
# [function] import_scip_file @ src/commands/memory/code_graph.rs:200
JSON output (--json):
[
{
"kind": "function",
"name": "import_scip_file",
"file_path": "src/commands/memory/code_graph.rs",
"line_number": 200
}
]
callers¶
Find all CodeFunction nodes that call a given function. Uses the CALLS
relationship edges in the graph.
| Argument | Description |
|---|---|
<NAME> |
Substring matching the callee's function name. |
Example:
amplihack query-code callers import_scip_file
# run_index_scip (src/commands/memory/scip_indexing.rs:113)
# import_scip_file (src/commands/memory/code_graph.rs:200) <- direct self-reference if any
callees¶
Find all CodeFunction nodes called by a given function. The inverse of
callers.
| Argument | Description |
|---|---|
<NAME> |
Substring matching the caller's function name. |
Example:
amplihack query-code callees run_index_scip
# run_native_scip_indexing (src/commands/memory/scip_indexing.rs:172)
# import_scip_file (src/commands/memory/code_graph.rs:200)
JSON output¶
Pass --json to any subcommand to receive machine-readable JSON on stdout.
Errors still go to stderr.
Exit codes¶
| Code | Meaning |
|---|---|
| 0 | Query completed successfully (zero results is still exit 0) |
| 1 | Error opening the database, or internal query failure |
Related commands¶
amplihack index-scip— Build the graph from sourceamplihack index-code— Import a blarify JSON- LadybugDB Code Graph Architecture — Schema and data model
- Index a project end-to-end — Walkthrough