Skip to content

Repo navigation

When an agent or user needs to find code, explain relationships, or prepare a compact evidence bundle before editing, foxctl provides a layered navigation system. This page covers each search surface, when to use it, and practical examples.

SurfaceCommandBest use
Semantic searchfoxctl run code/semantic_searchCross-source retrieval (symbols, sessions, memories, tasks, codemaps)
Smart searchfoxctl run code/smart_searchCode-file retrieval plus evidence extraction in one step
Snippet extractfoxctl run code/snippet_extractAnchor-aware code evidence extraction from known candidate files
Context grepfoxctl run code/context_grepPattern search returning full function/block bodies
Repo graph indexfoxctl index repo build/search/expandStructural relationships (calls, refs, imports)
DAG grepfoxctl run code/dag_grepCompact explanation subgraph in one call
Need to find code?
├── Topic is fuzzy or you need orientation?
│ → Semantic search (tree mode)
├── Need snippets and candidates in one step?
│ → Smart search
├── Already have candidate files?
│ → Snippet extract
├── Searching for a specific pattern?
│ → Context grep
└── Need to understand relationships?
├── Build the repo index first
└── Use expand or DAG grep

Semantic search finds code by meaning, not just text matching. Use it first when the topic is fuzzy, when you need a tree-shaped orientation of the codebase, or when searching across multiple source types.

Terminal window
foxctl run code/semantic_search --input '{"query": "auth middleware"}'
Terminal window
foxctl run code/semantic_search --input '{"query": "storage", "format": "tree", "limit": 25}'

Tree output includes:

  • Hierarchical directory structure with relevance scores
  • LLM-generated summaries for each file
  • Root summary synthesizing the codebase area

Tree options:

OptionDefaultDescription
tree_depth2Depth levels (0 = unlimited)
tree_max_children50Maximum items per directory
tree_include_summariestrueInclude file summaries

Filter by source type using the scope parameter:

Terminal window
foxctl run code/semantic_search --input '{"query": "error handling", "scope": ["symbols", "memories"]}'

Valid scope values: symbols, sessions, memories, tasks, codemaps.

FieldTypeNotes
querystringRequired unless format:"tree"
scopestring[]Source types to search
limitintDefault 20
min_similarityfloatDefault 0.3
formatstringjson (default) or tree
repo_index_modestringauto, search, dag, off (symbol/code scopes only)
remote / globalboolCross-workspace remote search
rerank_enabledboolEnable model-based reranking

When searching symbol or code scopes, repo_index_mode controls how the repo graph index contributes:

ModeBehavior
auto (default)Repo-index search first, DAG fallback when no hits
searchPrecise structural queries, most direct entrypoints
dagBroader graph exploration, neighborhood context
offDisables repo-index contribution

Smart search auto-generates candidates from indexes and then extracts relevant snippets. Use it when you need code snippets in one step without separately managing candidate lists.

Terminal window
foxctl run code/smart_search --input '{"query": "how does session restore work"}'

Smart search combines semantic search (the “find” step) and snippet extraction (the “extract” step) into a single call.

Terminal window
foxctl run code/smart_search --input '{"query": "error types", "glob": "*.go"}'

Output includes extracted snippets with full function bodies and surrounding code context.

Use snippet extraction when you already have candidate files (from semantic search or a manual list) and need anchor-aware evidence extraction.

Terminal window
foxctl run code/snippet_extract --input '{
"query": "authentication logic",
"candidates": [
{"path": "internal/auth/handler.go", "line": 45},
{"path": "internal/auth/middleware.go", "line": 12}
]
}'

Extraction modes:

ModeDescription
snippets (default)Full code snippets with context
maskedStructure only, implementation hidden
flowControl flow extraction

Context grep searches for patterns and returns complete surrounding blocks (functions, methods, classes) rather than just matching lines:

Terminal window
foxctl run code/context_grep --input '{"pattern": "func.*Handle", "path": "."}'
Terminal window
foxctl run code/context_grep --input '{
"pattern": "class.*Service",
"path": "src/",
"glob": "*.py"
}'

Context grep supports ripgrep, ast-grep (structural), and line expansion modes:

ModeTriggerUse for
ripgrep (default)Regex patternText pattern matching
astast_pattern parameterStructural code patterns
linefile_path + line rangeExpanding specific line ranges

The repo graph index is a local, per-repo SQLite database for navigating code by structural relationships. It powers call graphs, import trees, and reference lookups.

Nodes: package, file, symbol, concept

Edges: CONTAINS, IMPORTS, REFERS_TO, CALLS

Language coverage:

LanguageNodesEdges
GoPackages, files, symbolsIMPORTS, REFERS_TO, CALLS
TypeScript (.ts/.tsx)Packages, files, symbolsIMPORTS, heuristic CALLS
Elixir (.ex/.exs)Packages, files, symbolsHeuristic REFERS_TO
Terraform (.tf)Packages, files, conceptsResource/module/provider nodes
Kubernetes manifestsPackages, files, conceptsResource nodes
Shell (.sh)Packages, files, conceptsCommand and env var nodes
Terminal window
# Build with Go and TypeScript
foxctl index repo build --workspace . --go --typescript
# Include Elixir
foxctl index repo build --workspace . --go --typescript --elixir
# Infrastructure and script indexing
foxctl index repo build --workspace . --terraform --kubernetes --shell
# Force a full rebuild (incremental is default)
foxctl index repo build --workspace . --go --typescript --incremental=false

Optional build flags:

FlagDescription
--incremental=falseForce a full rebuild
--include-testsIndex test files
--go-pattern ./...Scope Go packages
--include-semantic-anchorsInclude semantic anchor concept nodes
--include-cochangeInclude empirical git co-change file edges

Repo index build does not attach summaries. Generate and attach them separately:

Terminal window
foxctl index file-summaries --workspace .
foxctl index symbol-summaries --workspace .
foxctl index repo enrich summaries --workspace .
Terminal window
# Full-text search
foxctl index repo search --workspace . --query "Supervisor" --limit 10
# Open a specific node by ID
foxctl index repo open --workspace . --id "<node-id>"
# Ask a natural language question (LLM tool loop over repoindex)
foxctl index repo ask --workspace . --question "Where is repoindex built?"
Terminal window
foxctl index repo expand --workspace . \
--seed "<node-id>" \
--edge CALLS --edge REFERS_TO \
--direction out \
--depth 2 \
--budget 50

Expand parameters:

ParameterDefaultDescription
--seedStarting node ID (required)
--edgeAll edgesEdge types to traverse (repeatable)
--directionoutout or in
--depth1Traversal depth
--budget50Maximum nodes to return
Terminal window
foxctl index repo status --workspace .

Index databases are stored at ~/.foxctl/storage/repoindex/<repo>-repoindex-<hash>.db.

DAG grep produces a compact explanation subgraph in one call. It is the better default when the question is about graph relationships rather than text snippets.

Terminal window
foxctl run code/dag_grep --input '{
"query": "buildEvidencePack",
"workspace": ".",
"render": "tree",
"edge_sets": ["structural"],
"depth": 2,
"budget": 80,
"k": 5
}'

DAG grep parameters:

ParameterDefaultDescription
querySearch query for seed nodes
workspace.Workspace root
rendertree or mermaid output format
edge_setsEdge sets to include (e.g., ["structural"])
depth2Traversal depth
budget80Maximum nodes to return
k10Number of seed nodes
modehybridSearch mode: fts, semantic, or hybrid

Chain tools for comprehensive code understanding:

semantic_search → snippet_extract → analysis
"where" "what" "meaning"
Terminal window
# 1. Find candidates with semantic search
foxctl run code/semantic_search --input '{"query": "error handling"}'
# 2. Extract snippets from the candidates
foxctl run code/snippet_extract --input '{
"query": "error handling patterns",
"candidates": [
{"path": "internal/errors/handler.go", "line": 45}
]
}'
# 3. Or use smart search for steps 1+2 combined
foxctl run code/smart_search --input '{"query": "error handling patterns"}'
# 4. For relationship questions, build the index and use DAG grep
foxctl index repo build --workspace . --go --typescript
foxctl run code/dag_grep --input '{"query": "HandleError", "render": "tree", "depth": 2}'
SymptomLikely cause
Empty semantic matches for vector-only scopesMissing or unreachable OpenAI-compatible embedding endpoint
Dimension mismatchModel/store dimension drift; rebuild the affected scope
Rerank unavailableMissing key or FOXCTL_RERANK_ENABLED not set
Empty repoindex resultsIndex not built or stale; rebuild with foxctl index repo build
Missing TypeScript edgesTypeScript adds heuristic CALLS edges; ambiguous targets are skipped

When the documentation or agents say “index this,” assume they mean making the material queryable to agents through repoindex and related semantic/vector stores.

  • Repoindex: The per-workspace graph behind foxctl index repo ... and repo_index_* tools.
  • Symbol: A named code declaration (function, type, method) that repoindex can navigate.
  • Node: A graph record — commonly a package, file, symbol, or concept.
  • Edge: A typed relationship between nodes (e.g., CONTAINS, CALLS, REFERS_TO).
  • Index: comment block: Structured source metadata for discoverability and soft graph edges.
  • Semantic anchor: A typed [[type:slug]] evidence marker near a strong owner — evidence for retrieval, not instructions.