CodeAlive Context Engine
Semantic code intelligence across your entire code ecosystem — current project, organizational repos, dependencies, and any indexed codebase.
Authentication
All scripts require a CodeAlive API key. If any script fails with "API key not configured", help the user set it up:
Option 1 (recommended): Run the interactive setup and wait for the user to complete it:
CODEBLOCK0
Option 2 (not recommended — key visible in chat history): If the user pastes their API key directly in chat, save it via:
CODEBLOCK1
Do NOT retry the failed script until setup completes successfully.
Table of Contents
Tools Overview
| Tool | Script | Speed | Cost | Best For |
|---|
| List Data Sources | INLINECODE0 | Instant | Free | Discovering indexed repos and workspaces |
| Search |
search.py | Fast | Low | Finding code locations, descriptions, identifiers |
|
Fetch Artifacts |
fetch.py | Fast | Low | Retrieving full content for search results |
|
Chat with Codebase |
chat.py | Slow | High | Synthesized answers, architectural explanations |
|
Explore |
explore.py | Slow | High | Multi-step discovery workflows |
Cost guidance: Search is lightweight and should be the default starting point. Chat with Codebase invokes an LLM on the server side, making it significantly more expensive per call — use it when you need a synthesized, ready-to-use answer rather than raw search results.
Three-step workflow:
- 1. Search — find relevant code locations with descriptions and identifiers
- Review — examine the descriptions to understand what each result contains
- Get content — use
fetch.py for external repos or Read() for local files
When to Use
Use this skill for semantic understanding:
- - "How is authentication implemented?"
- "Show me error handling patterns across services"
- "How does this library work internally?"
- "Find similar features to guide my implementation"
Use local file tools instead for:
- - Finding specific files by name or pattern
- Exact keyword search in the current directory
- Reading known file paths
- Searching uncommitted changes
Quick Start
1. Discover what's indexed
CODEBLOCK2
2. Search for code (fast, cheap)
CODEBLOCK3
3. Fetch full content (for external repos)
CODEBLOCK4
4. Chat with codebase (slower, richer answers)
CODEBLOCK5
5. Multi-step exploration
CODEBLOCK6
Tool Reference
datasources.py — List Data Sources
CODEBLOCK7
search.py — Semantic Code Search
Returns file paths, line numbers, descriptions, identifiers, and content sizes. Fast and cheap.
CODEBLOCK8
| Option | Description |
|---|
| INLINECODE9 | Default. Intelligent semantic search — use 80% of the time |
| INLINECODE10 |
Quick lexical search for known terms |
|
--mode deep | Exhaustive search for complex cross-cutting queries. Resource-intensive |
|
--description-detail short | Default. Brief description of each result |
|
--description-detail full | More detailed description of each result |
Getting content: Search returns descriptions and identifiers. For the current repo, use Read() on the file paths. For external repos, use fetch.py with the identifiers.
fetch.py — Fetch Artifact Content
Retrieves the full source code content for artifacts found via search. Use this for external repositories you cannot access locally.
CODEBLOCK9
| Constraint | Value |
|---|
| Max identifiers per request | 20 |
| Identifiers source |
identifier field from search results |
| Identifier format |
{owner/repo}::{path}::{symbol} (symbols),
{owner/repo}::{path} (files) |
chat.py — Chat with Codebase
Sends your question to an AI consultant that has full context of the indexed codebase. Returns synthesized, ready-to-use answers. Supports conversation continuity for follow-ups.
This is more expensive than search because it runs an LLM inference on the server side. Prefer search when you just need to locate code. Use chat when you need explanations, comparisons, or architectural analysis.
CODEBLOCK10
| Option | Description |
|---|
| INLINECODE21 | Continue a previous conversation (saves context and cost) |
Conversation continuity: Every response includes a conversation_id. Pass it with --continue for follow-up questions — this preserves context and is cheaper than starting fresh.
explore.py — Smart Exploration
Combines search and chat-with-codebase in multi-step workflows. Useful for complex investigations.
CODEBLOCK11
| Mode | Purpose |
|---|
| INLINECODE25 | Search + explanation |
| INLINECODE26 |
Library usage and internals |
|
pattern:<pattern> | Cross-project pattern discovery |
|
implement:<feature> | Find similar features for guidance |
|
debug:<issue> | Trace symptom to root cause |
Data Sources
Repository — single codebase, for targeted searches:
CODEBLOCK12
Workspace — multiple repos, for cross-project patterns:
CODEBLOCK13
Multiple repositories:
CODEBLOCK14
Configuration
Prerequisites
- - Python 3.8+ (no third-party packages required — uses only stdlib)
API Key Setup
The skill needs a CodeAlive API key. Resolution order:
- 1.
CODEALIVE_API_KEY environment variable - OS credential store (macOS Keychain / Linux secret-tool / Windows Credential Manager)
Environment variable (all platforms):
CODEBLOCK15
macOS Keychain:
CODEBLOCK16
Linux (freedesktop secret-tool):
CODEBLOCK17
Windows Credential Manager:
CODEBLOCK18
Base URL (optional, defaults to https://app.codealive.ai):
CODEBLOCK19
Get API keys at: https://app.codealive.ai/settings/api-keys
Using with CodeAlive MCP Server
This skill works standalone, but delivers the best experience when combined with the CodeAlive MCP server. The MCP server provides direct tool access via the Model Context Protocol, while this skill provides the workflow knowledge and query patterns to use those tools effectively.
| Component | What it provides |
|---|
| This skill | Query patterns, workflow guidance, cost-aware tool selection |
| MCP server |
Direct
codebase_search,
fetch_artifacts,
codebase_consultant,
get_data_sources tools |
When both are installed, prefer the MCP server's tools for direct operations and this skill's scripts for guided multi-step workflows like explore.py.
Detailed Guides
For advanced usage, see reference files:
- - Query Patterns — effective query writing, anti-patterns, language-specific examples
- Workflows — step-by-step workflows for onboarding, debugging, feature planning, and more
CodeAlive 上下文引擎
跨整个代码生态系统的语义代码智能——当前项目、组织仓库、依赖项以及任何已索引的代码库。
身份验证
所有脚本都需要 CodeAlive API 密钥。如果任何脚本因API 密钥未配置而失败,请帮助用户进行设置:
选项 1(推荐): 运行交互式设置并等待用户完成:
bash
python setup.py
选项 2(不推荐——密钥会显示在聊天历史中): 如果用户直接在聊天中粘贴其 API 密钥,请通过以下方式保存:
bash
python setup.py --key THE_KEY
在设置成功完成之前,不要重试失败的脚本。
目录
工具概览
| 工具 | 脚本 | 速度 | 成本 | 最佳用途 |
|---|
| 列出数据源 | datasources.py | 即时 | 免费 | 发现已索引的仓库和工作空间 |
| 搜索 |
search.py | 快速 | 低 | 查找代码位置、描述、标识符 |
|
获取工件 | fetch.py | 快速 | 低 | 检索搜索结果的完整内容 |
|
与代码库对话 | chat.py | 慢速 | 高 | 综合答案、架构解释 |
|
探索 | explore.py | 慢速 | 高 | 多步骤发现工作流 |
成本指导: 搜索是轻量级的,应作为默认起点。与代码库对话会在服务器端调用 LLM,使其每次调用成本显著更高——当您需要综合的、可直接使用的答案而非原始搜索结果时使用。
三步工作流:
- 1. 搜索 — 查找带有描述和标识符的相关代码位置
- 审查 — 检查描述以了解每个结果包含的内容
- 获取内容 — 对外部仓库使用 fetch.py,对本地文件使用 Read()
使用时机
将此技能用于语义理解:
- - 身份验证是如何实现的?
- 显示跨服务的错误处理模式
- 这个库内部是如何工作的?
- 查找类似功能以指导我的实现
在以下情况下使用本地文件工具:
- - 按名称或模式查找特定文件
- 在当前目录中进行精确关键词搜索
- 读取已知文件路径
- 搜索未提交的更改
快速入门
1. 发现已索引的内容
bash
python scripts/datasources.py
2. 搜索代码(快速、便宜)
bash
python scripts/search.py JWT 令牌验证 my-backend
python scripts/search.py 错误处理模式 workspace:platform-team --mode deep
python scripts/search.py 身份验证流程 my-repo --description-detail full
3. 获取完整内容(适用于外部仓库)
bash
python scripts/fetch.py my-org/backend::src/auth.py::AuthService.login()
4. 与代码库对话(较慢、更丰富的答案)
bash
python scripts/chat.py 解释身份验证流程 my-backend
python scripts/chat.py 安全性考虑呢? --continue CONV_ID
5. 多步骤探索
bash
python scripts/explore.py understand:用户身份验证 my-backend
python scripts/explore.py debug:慢速数据库查询 my-service
工具参考
datasources.py — 列出数据源
bash
python scripts/datasources.py # 可直接使用的源
python scripts/datasources.py --all # 所有源(包括处理中的)
python scripts/datasources.py --json # JSON 输出
search.py — 语义代码搜索
返回文件路径、行号、描述、标识符和内容大小。快速且便宜。
bash
python scripts/search.py <查询> <数据源...> [选项]
| 选项 | 描述 |
|---|
| --mode auto | 默认。智能语义搜索——80% 的情况下使用 |
| --mode fast |
快速词汇搜索,适用于已知术语 |
| --mode deep | 详尽搜索,适用于复杂的跨领域查询。资源密集型 |
| --description-detail short | 默认。每个结果的简要描述 |
| --description-detail full | 每个结果的更详细描述 |
获取内容: 搜索返回描述和标识符。对于当前仓库,对文件路径使用 Read()。对于外部仓库,使用带有标识符的 fetch.py。
fetch.py — 获取工件内容
检索通过搜索找到的工件的完整源代码内容。用于无法本地访问的外部仓库。
bash
python scripts/fetch.py <标识符1> [标识符2...]
搜索结果中的 identifier 字段 |
| 标识符格式 | {所有者/仓库}::{路径}::{符号}(符号),{所有者/仓库}::{路径}(文件) |
chat.py — 与代码库对话
将您的问题发送给拥有已索引代码库完整上下文的 AI 顾问。返回综合的、可直接使用的答案。支持对话连续性以进行后续提问。
这比搜索更昂贵,因为它在服务器端运行 LLM 推理。当您只需要定位代码时,优先使用搜索。当您需要解释、比较或架构分析时,使用聊天。
bash
python scripts/chat.py <问题> <数据源...> [选项]
| 选项 | 描述 |
|---|
| --continue <id> | 继续之前的对话(保存上下文和成本) |
对话连续性: 每个响应都包含一个 conversation_id。使用 --continue 传递它以进行后续提问——这可以保留上下文,并且比从头开始更便宜。
explore.py — 智能探索
在多步骤工作流中结合搜索和与代码库对话。适用于复杂调查。
bash
python scripts/explore.py <模式:查询> <数据源...>
| 模式 | 用途 |
|---|
| understand:<主题> | 搜索 + 解释 |
| dependency:<库> |
库的使用和内部机制 |
| pattern:<模式> | 跨项目模式发现 |
| implement:<功能> | 查找类似功能以获取指导 |
| debug:<问题> | 从症状追踪到根本原因 |
数据源
仓库 — 单个代码库,用于针对性搜索:
bash
python scripts/search.py 查询 my-backend-api
工作空间 — 多个仓库,用于跨项目模式:
bash
python scripts/search.py 查询 workspace:backend-team
多个仓库:
bash
python scripts/search.py 查询 repo-a repo-b repo-c
配置
前提条件
- - Python 3.8+(不需要第三方包——仅使用标准库)
API 密钥设置
该技能需要 CodeAlive API 密钥。解析顺序:
- 1. CODEALIVEAPIKEY 环境变量
- 操作系统凭据存储(macOS Keychain / Linux secret-tool / Windows Credential Manager)
环境变量(所有平台):
bash
export CODEALIVEAPIKEY=yourkeyhere
macOS Keychain:
bash
security add-generic-password -a $USER -s codealive-api-key -w YOURAPIKEY
Linux(freedesktop secret-tool):
bash
secret-tool store --label=CodeAlive API Key service codealive-api-key
Windows Credential Manager:
cmd
cmdkey /generic:codealive-api-key /user:codealive /pass:YOURAPIKEY
基础 URL(可选,默认为 https://app.codealive.ai):
bash
export CODEALIVEBASEURL=https://your-instance.example.com
在以下位置获取 API 密钥:https://app.codealive.ai/settings/api-keys
与 CodeAlive MCP 服务器一起使用
此技能可独立运行,但与 CodeAlive MCP 服务器 结合使用时能提供最佳体验。MCP 服务器通过模型上下文协议提供直接工具访问,而此技能提供有效使用这些工具所需的工作流知识和查询模式。
| 组件 | 提供的内容 |
|---|
| 此技能 | 查询模式、工作流指导、成本感知工具选择 |
| MCP 服务器 |
直接的 codebase_search、fetch