Agent Skills › giancarloerra/SocratiCode

giancarloerra/SocratiCode

GitHub

利用SocratiCode工具高效探索代码库。核心原则是先搜索后阅读,通过混合语义/关键词搜索定位文件,借助依赖图分析架构与循环依赖,最后仅读取关键片段。支持查询数据库Schema、API规范等非代码知识,避免盲目读取大文件以节省上下文。

2 skills 3,086

Install All Skills

npx skills add giancarloerra/SocratiCode --all -g -y
More Options

List skills in collection

npx skills add giancarloerra/SocratiCode --list

Skills in Collection (2)

利用SocratiCode工具高效探索代码库。核心原则是先搜索后阅读,通过混合语义/关键词搜索定位文件,借助依赖图分析架构与循环依赖,最后仅读取关键片段。支持查询数据库Schema、API规范等非代码知识,避免盲目读取大文件以节省上下文。
询问代码结构或架构 查找特定功能或函数的位置 理解代码组织方式 分析依赖关系 搜索数据库模式或API规范
skills/codebase-exploration/SKILL.md
npx skills add giancarloerra/SocratiCode --skill codebase-exploration -g -y
SKILL.md
Frontmatter
{
    "name": "codebase-exploration",
    "description": "Explore and understand codebases using SocratiCode semantic search, dependency graphs, and context artifacts. Use when exploring code, understanding architecture, finding functions\/types, analysing dependencies, searching database schemas or API specs, or when socraticode\/codebase_search tools are available. Activates when the user asks about code structure, wants to find where a feature lives, or needs to understand how code is organised."
}

SocratiCode Codebase Exploration

Use SocratiCode MCP tools to explore codebases efficiently. The core principle: search before reading — the index gives you a map of the codebase in milliseconds; raw file reading is expensive and context-consuming.

Workflow

1. Start most explorations with codebase_search

Hybrid semantic + keyword search (vector + BM25, RRF-fused) runs in a single call.

  • Broad queries for orientation: "how is authentication handled", "database connection setup", "error handling patterns"
  • Precise queries for symbol lookup: exact function names, constants, type names
  • Prefer search results to infer which files to read — do not speculatively open files
  • Use fileFilter to narrow to a specific file path, languageFilter for a specific language
  • Adjust minScore (default 0.10) for precision vs recall — lower for more results, higher for stricter matching

When to use grep instead: If you already know the exact identifier, error string, or regex pattern, grep/ripgrep is faster and more precise — no semantic gap to bridge. Use codebase_search when exploring, asking conceptual questions, or when you don't know which files to look in.

2. Follow the graph before following imports

Use codebase_graph_query to see what a file imports and what depends on it before diving into its contents. This prevents unnecessary reading of transitive dependencies.

  • codebase_graph_query — imports and dependents for any file (pass relative path)
  • codebase_graph_stats — architecture overview: total files, edges, most connected files, orphans, language breakdown
  • codebase_graph_circular — find circular dependencies (these cause subtle runtime bugs; check proactively when debugging unexpected behaviour)
  • codebase_graph_visualize — Mermaid diagram colour-coded by language, circular deps highlighted in red. Pass mode: "interactive" to open a self-contained HTML explorer (file + symbol views, blast-radius overlay, search, PNG export — works offline) instead.

The graph is auto-built after indexing. Use codebase_graph_status to check if the graph is ready.

3. Read files only after narrowing via search

Once search results clearly point to 1-3 files, read only the relevant sections. Never read a file just to find out if it's relevant — search first.

A single codebase_search call returns ranked, deduplicated snippets from across the entire codebase in milliseconds. This gives you a broad map at negligible token cost — far cheaper than opening files speculatively.

4. Leverage context artifacts for non-code knowledge

Projects can define a .socraticodecontextartifacts.json config to expose database schemas, API specs, infrastructure configs, architecture docs, and other project knowledge that lives outside source code.

  • codebase_context — list available artifacts (names, descriptions, paths, index status)
  • codebase_context_search — semantic search across all artifacts (or filter with artifactName)
  • Artifacts are auto-indexed on first search and auto-detect staleness

Run codebase_context early to see what's available. Use codebase_context_search before asking about database structure, API contracts, or infrastructure.

5. Check status if something seems wrong

  • codebase_status — check index status, progress, watcher state, graph status
  • If search returns no results, the project may not be indexed yet
  • If the watcher is inactive, results may be stale — run codebase_update or start the watcher

6. Get an overview of all tools

  • codebase_about — quick reference of all SocratiCode tools and a typical workflow

Goal → Tool Quick Reference

Goal Tool
Understand what a codebase does / where a feature lives codebase_search (broad query)
Find a specific function, constant, or type codebase_search (exact name) or grep
Find exact error messages, log strings, or regex patterns grep / ripgrep
See what a file imports or what depends on it codebase_graph_query
Get architecture overview (files, edges, most connected) codebase_graph_stats
Spot circular dependencies codebase_graph_circular
Visualise module structure (text / Mermaid) codebase_graph_visualize
User asks for a visual / interactive / shareable graph codebase_graph_visualize mode="interactive"
Check graph build status codebase_graph_status
Verify index is up to date codebase_status
Discover available schemas, specs, configs codebase_context
Find database tables, API endpoints, infra configs codebase_context_search
Quick overview of all tools codebase_about

For full parameter details on every tool, see references/tool-reference.md.

管理 SocratiCode 代码库索引,涵盖首次设置、增量更新、文件监听、代码图及上下文工件配置。用于索引项目、排查基础设施问题或执行管理员任务。
用户希望索引项目 检查基础设施健康状态 启动或停止文件监听 配置上下文工件 排查索引问题 管理代码图 提及 SocratiCode 索引或搜索设置
skills/codebase-management/SKILL.md
npx skills add giancarloerra/SocratiCode --skill codebase-management -g -y
SKILL.md
Frontmatter
{
    "name": "codebase-management",
    "description": "Set up, index, and manage SocratiCode codebase indexing. Use when the user wants to index a project, check infrastructure health, start\/stop file watching, configure context artifacts, troubleshoot indexing issues, manage the code graph, or any SocratiCode administrative task. Activates when the user mentions indexing, setting up search, SocratiCode infrastructure, or managing the codebase index."
}

SocratiCode Management

Set up, index, and manage SocratiCode codebase indexing, file watching, code graphs, and context artifacts.

First-Time Setup

  1. Check infrastructure: codebase_health — verifies Docker, Qdrant, Ollama/embedding provider, and embedding model
  2. Start indexing: codebase_index — runs in background, returns immediately
  3. Poll progress: codebase_status — call every ~60 seconds until 100% complete
    • This also keeps the MCP connection alive (some hosts disconnect idle connections)
  4. Done: Graph auto-builds after indexing. File watcher auto-starts. Ready to search.

On first use, SocratiCode automatically pulls Docker images, starts containers, and downloads the embedding model (~5 min one-time setup).

Incremental Updates & File Watching

The file watcher keeps the index automatically updated. It auto-starts after indexing.

  • codebase_watch { action: "start" } — start the watcher (runs catch-up update first)
  • codebase_watch { action: "stop" } — stop the watcher
  • codebase_watch { action: "status" } — list watched projects (including cross-process)
  • codebase_update — manual incremental update (only changed files, synchronous). Usually not needed if watcher is active.

Managing Indexes

  • codebase_stop — gracefully pause in-progress indexing. Current batch finishes and checkpoints. All progress preserved. Resume with codebase_index.
  • codebase_remove — delete entire index (destructive). Safely stops watcher, cancels indexing, waits for graph builds.
  • codebase_list_projects — list all indexed projects with metadata, graph info, and artifact status.

Managing the Code Graph

The dependency graph is auto-built after indexing. Manual management is rarely needed.

  • codebase_graph_build — manually rebuild (background, async). Poll with codebase_graph_status.
  • codebase_graph_remove — delete graph (auto-rebuilds on next codebase_index)
  • codebase_graph_status — check build progress or graph readiness

Context Artifacts Setup

To index non-code knowledge, create .socraticodecontextartifacts.json in the project root:

{
  "artifacts": [
    {
      "name": "database-schema",
      "path": "./docs/schema.sql",
      "description": "PostgreSQL schema — all tables, indexes, constraints, foreign keys."
    }
  ]
}

Supported types: SQL schemas, OpenAPI/Protobuf API specs, Terraform/CloudFormation configs, Kubernetes manifests, architecture docs, environment configs — any text-based file or directory.

  • codebase_context_index — manually index/re-index all artifacts (usually auto-triggered)
  • codebase_context_remove — remove all indexed artifacts (blocked during indexing)

Troubleshooting

Problem Solution
Docker not available Install Docker Desktop from https://docker.com, ensure it's running
Slow indexing on macOS/Windows Docker can't use GPU. Install native Ollama from https://ollama.com/download for Metal/CUDA acceleration. Or use cloud embeddings.
Want cloud embeddings instead Set EMBEDDING_PROVIDER=openai + OPENAI_API_KEY, or EMBEDDING_PROVIDER=google + GOOGLE_API_KEY
Search returns no results Check codebase_status — project may not be indexed. Run codebase_index.
Stale results Check if watcher is active (codebase_status). Run codebase_update or codebase_watch { action: "start" }.
Indexing was interrupted Run codebase_index again — it resumes from the last checkpoint automatically.
Another process is indexing codebase_status detects cross-process indexing. Wait for it, or use codebase_stop.

Key Environment Variables

Variable Default Description
QDRANT_MODE managed managed (Docker) or external (remote/cloud Qdrant)
QDRANT_URL Full URL for remote Qdrant (e.g. https://xyz.cloud.qdrant.io:6333)
QDRANT_API_KEY API key for remote Qdrant
EMBEDDING_PROVIDER ollama ollama, openai, or google
OPENAI_API_KEY Required when EMBEDDING_PROVIDER=openai
GOOGLE_API_KEY Required when EMBEDDING_PROVIDER=google
OLLAMA_MODE auto auto (detect native, fallback Docker), docker, external
EMBEDDING_MODEL nomic-embed-text Model name (provider-specific)
SEARCH_DEFAULT_LIMIT 10 Default result limit for codebase_search (1-50)
SEARCH_MIN_SCORE 0.10 Default minimum RRF score threshold (0-1)
MAX_FILE_SIZE_MB 5 Maximum file size for indexing in MB
EXTRA_EXTENSIONS Additional file extensions to index (e.g. .tpl,.blade,.hbs)

For full parameter details on every tool, see references/tool-reference.md.

Home - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-07-13 14:04
浙ICP备14020137号-1 $Map of visitor$