codesight-ai-context
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCodeSight — AI Context Generator
CodeSight — AI 上下文生成器
Skill by ara.so — Daily 2026 Skills collection.
CodeSight compiles your codebase into a compact, structured context map (routes, models, components, dependencies) that AI coding assistants can read in one shot — eliminating thousands of tokens spent on manual file exploration. Supports 14 languages, 30+ frameworks, 13 ORM parsers, and an MCP server with 13 tools.
由 ara.so 开发的Skill — 2026年度技能合集收录项目。
CodeSight 可将你的代码库编译为紧凑的结构化上下文映射(包含路由、模型、组件、依赖),AI编码助手可以一次性读取,省去了手动探索文件消耗的数千token。支持14种语言、30+框架、13种ORM解析器,以及自带13个工具的MCP服务器。
Installation
安装
No installation required. Run directly with :
npxbash
npx codesightOr install globally:
bash
npm install -g codesight
codesightRequirements: Node.js >= 18, no API keys, no config files needed.
无需安装,直接通过运行:
npxbash
npx codesight或者全局安装:
bash
npm install -g codesight
codesight要求: Node.js >= 18,无需API密钥,无需配置文件。
Core Commands
核心命令
bash
undefinedbash
undefinedGenerate context map (default — outputs .codesight/CODESIGHT.md)
生成上下文映射(默认输出到 .codesight/CODESIGHT.md)
npx codesight
npx codesight
Generate persistent wiki knowledge base (.codesight/wiki/)
生成持久化Wiki知识库(.codesight/wiki/)
npx codesight --wiki
npx codesight --wiki
Generate AI tool config files (CLAUDE.md, .cursorrules, codex.md, AGENTS.md)
生成AI工具配置文件(CLAUDE.md、.cursorrules、codex.md、AGENTS.md)
npx codesight --init
npx codesight --init
Open interactive HTML report in browser
在浏览器中打开交互式HTML报告
npx codesight --open
npx codesight --open
Start as MCP server (13 tools) for Claude Code / Cursor
作为MCP服务器启动(包含13个工具),供Claude Code / Cursor使用
npx codesight --mcp
npx codesight --mcp
Show blast radius for a specific file
展示指定文件的影响范围
npx codesight --blast src/lib/db.ts
npx codesight --blast src/lib/db.ts
Generate optimized config for a specific AI tool
为指定AI工具生成优化配置
npx codesight --profile claude-code
npx codesight --profile cursor
npx codesight --profile copilot
npx codesight --profile codex
npx codesight --profile claude-code
npx codesight --profile cursor
npx codesight --profile copilot
npx codesight --profile codex
Show token savings breakdown
展示Token节省明细
npx codesight --benchmark
npx codesight --benchmark
Map markdown knowledge base (ADRs, meeting notes, Obsidian vault)
映射Markdown知识库(架构决策记录、会议记录、Obsidian vault)
npx codesight --mode knowledge
npx codesight --mode knowledge ~/vault
npx codesight --mode knowledge ./docs
npx codesight --mode knowledge
npx codesight --mode knowledge ~/vault
npx codesight --mode knowledge ./docs
Watch mode — regenerate on file changes
监听模式 — 文件变更时自动重新生成
npx codesight --watch
npx codesight --watch
Git hook — regenerate on every commit
Git钩子 — 每次提交时自动重新生成
npx codesight --hook
undefinednpx codesight --hook
undefinedWhat Gets Generated
生成内容说明
Default Scan (npx codesight
)
npx codesight默认扫描(npx codesight
)
npx codesightOutputs — a structured map including:
.codesight/CODESIGHT.md- Project metadata (stack, language, framework, package manager)
- All routes with HTTP methods and handler locations
- Database models with fields and relations
- UI components with props
- High-impact files ranked by dependency count
- Framework and ORM detection results
输出 — 结构化映射包含:
.codesight/CODESIGHT.md- 项目元数据(技术栈、语言、框架、包管理器)
- 所有路由,包含HTTP方法和处理函数位置
- 数据库模型,包含字段和关联关系
- UI组件,包含props定义
- 按依赖数量排序的高影响文件
- 框架和ORM检测结果
Wiki Knowledge Base (--wiki
)
--wikiWiki知识库(--wiki
)
--wikiOutputs directory:
.codesight/wiki/.codesight/wiki/
index.md — catalog of all articles (~200 tokens)
overview.md — architecture, subsystems, high-impact files
auth.md — auth routes, middleware, session flow
payments.md — payment routes, webhook handling, billing flow
database.md — all models, fields, relations
users.md — user management routes and models
ui.md — UI components with props
log.md — append-only operation log输出目录:
.codesight/wiki/.codesight/wiki/
index.md — 所有文档的目录(约200 token)
overview.md — 架构、子系统、高影响文件说明
auth.md — 认证路由、中间件、会话流程
payments.md — 支付路由、Webhook处理、计费流程
database.md — 所有模型、字段、关联关系
users.md — 用户管理路由和模型
ui.md — 带props的UI组件说明
log.md — 仅追加的操作日志AI Tool Config Files (--init
)
--initAI工具配置文件(--init
)
--initGenerates project-root files for each AI tool:
- — Claude Code project instructions
CLAUDE.md - — Cursor rules file
.cursorrules - — OpenAI Codex context
codex.md - — general agent instructions
AGENTS.md
为每个AI工具在项目根目录生成对应文件:
- — Claude Code项目说明
CLAUDE.md - — Cursor规则文件
.cursorrules - — OpenAI Codex上下文
codex.md - — 通用Agent说明
AGENTS.md
MCP Server Mode
MCP服务器模式
Start CodeSight as an MCP server to give Claude Code or Cursor direct tool access:
bash
npx codesight --mcp将CodeSight作为MCP服务器启动,让Claude Code或Cursor可以直接调用工具:
bash
npx codesight --mcpMCP Tool Reference
MCP工具参考
| Tool | Description |
|---|---|
| Full codebase context map |
| All API routes with methods and handlers |
| All database models and schema |
| UI components with props |
| Impact analysis for a specific file |
| Files ranked by dependency count |
| Detected frameworks and ORMs |
| Wiki catalog (~200 tokens) for session start |
| Read one wiki article by name |
| Wiki health check (orphans, stale, missing links) |
| Knowledge map from markdown notes |
| Token savings analysis |
| Project overview summary |
| 工具 | 描述 |
|---|---|
| 完整代码库上下文映射 |
| 所有API路由,包含方法和处理函数 |
| 所有数据库模型和Schema |
| 带props的UI组件 |
| 指定文件的影响分析 |
| 按依赖数量排序的文件列表 |
| 检测到的框架和ORM信息 |
| 会话启动用的Wiki目录(约200 token) |
| 按名称读取单篇Wiki文档 |
| Wiki健康检查(孤立文档、过期内容、缺失链接) |
| 从Markdown笔记生成的知识映射 |
| Token节省分析 |
| 项目概览摘要 |
Configuring MCP in Claude Code
在Claude Code中配置MCP
Add to your Claude Code MCP config ( or project ):
~/.claude/mcp_settings.json.mcp.jsonjson
{
"mcpServers": {
"codesight": {
"command": "npx",
"args": ["codesight", "--mcp"],
"cwd": "/path/to/your/project"
}
}
}添加到你的Claude Code MCP配置( 或项目级):
~/.claude/mcp_settings.json.mcp.jsonjson
{
"mcpServers": {
"codesight": {
"command": "npx",
"args": ["codesight", "--mcp"],
"cwd": "/path/to/your/project"
}
}
}Configuring MCP in Cursor
在Cursor中配置MCP
Add to in your project root:
.cursor/mcp.jsonjson
{
"mcpServers": {
"codesight": {
"command": "npx",
"args": ["codesight", "--mcp"]
}
}
}添加到项目根目录的:
.cursor/mcp.jsonjson
{
"mcpServers": {
"codesight": {
"command": "npx",
"args": ["codesight", "--mcp"]
}
}
}Language & Framework Support
语言与框架支持
| Language | AST Precision | Frameworks Detected |
|---|---|---|
| TypeScript | ✅ Full AST | Next.js, NestJS, Hono, Remix, SvelteKit, Nuxt, Express, Fastify |
| JavaScript | Regex | Express, Fastify, Koa, Hapi |
| Python | Regex | Django, FastAPI, Flask, SQLAlchemy |
| Go | Regex | Gin, Echo, Fiber, Chi |
| Ruby | Regex | Rails, Sinatra |
| PHP | Regex | Laravel, Symfony |
| Elixir | Regex | Phoenix |
| Java | Regex | Spring Boot |
| Kotlin | Regex | Ktor, Spring Boot |
| Rust | Regex | Axum, Actix |
| Dart | Regex | Flutter |
| Swift | Regex | Vapor |
| C# | Regex | ASP.NET Core |
| 语言 | AST精度 | 支持检测的框架 |
|---|---|---|
| TypeScript | ✅ 完整AST | Next.js、NestJS、Hono、Remix、SvelteKit、Nuxt、Express、Fastify |
| JavaScript | 正则匹配 | Express、Fastify、Koa、Hapi |
| Python | 正则匹配 | Django、FastAPI、Flask、SQLAlchemy |
| Go | 正则匹配 | Gin、Echo、Fiber、Chi |
| Ruby | 正则匹配 | Rails、Sinatra |
| PHP | 正则匹配 | Laravel、Symfony |
| Elixir | 正则匹配 | Phoenix |
| Java | 正则匹配 | Spring Boot |
| Kotlin | 正则匹配 | Ktor、Spring Boot |
| Rust | 正则匹配 | Axum、Actix |
| Dart | 正则匹配 | Flutter |
| Swift | 正则匹配 | Vapor |
| C# | 正则匹配 | ASP.NET Core |
ORM / Database Support
ORM/数据库支持
Drizzle, Prisma, TypeORM, Sequelize, Mongoose, MikroORM, SQLAlchemy, Django ORM, ActiveRecord, Eloquent, Ecto, GORM, and more (13 total).
Drizzle、Prisma、TypeORM、Sequelize、Mongoose、MikroORM、SQLAlchemy、Django ORM、ActiveRecord、Eloquent、Ecto、GORM等(共13种)。
Real Usage Patterns
实际使用场景
Pattern 1: Session Start with Wiki
场景1:会话启动时加载Wiki
At the beginning of every AI session, load the wiki index instead of the full context map:
undefined每次AI会话开始时,加载Wiki目录而非完整上下文映射:
undefinedIn Claude Code or Cursor, at session start:
在Claude Code或Cursor中,会话开始时执行:
Use codesight_get_wiki_index to get project overview,
then codesight_get_wiki_article for "auth" to understand authentication.
undefined使用codesight_get_wiki_index获取项目概览,
然后调用codesight_get_wiki_article获取"auth"相关内容了解认证逻辑。
undefinedPattern 2: Blast Radius Before Refactoring
场景2:重构前查询影响范围
Before modifying a shared file, check what breaks:
bash
npx codesight --blast src/lib/database.tsOutput shows every file that imports the target, ranked by impact — critical before refactoring database connections, shared utilities, or types.
修改共享文件前,检查会影响哪些内容:
bash
npx codesight --blast src/lib/database.ts输出会展示所有导入目标文件的文件,按影响程度排序 — 在重构数据库连接、共享工具函数或类型定义前非常重要。
Pattern 3: CI/CD Integration
场景3:CI/CD集成
Keep context fresh on every push:
yaml
undefined每次推送时更新上下文,保持内容新鲜:
yaml
undefined.github/workflows/codesight.yml
.github/workflows/codesight.yml
name: Update AI Context
on:
push:
branches: [main]
jobs:
update-context:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Generate context map
run: npx codesight
- name: Generate wiki
run: npx codesight --wiki
- name: Generate knowledge map
run: npx codesight --mode knowledge ./docs
- name: Commit updated context
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add .codesight/
git diff --staged --quiet || git commit -m "chore: update AI context [skip ci]"
git push
undefinedname: Update AI Context
on:
push:
branches: [main]
jobs:
update-context:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Generate context map
run: npx codesight
- name: Generate wiki
run: npx codesight --wiki
- name: Generate knowledge map
run: npx codesight --mode knowledge ./docs
- name: Commit updated context
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add .codesight/
git diff --staged --quiet || git commit -m "chore: update AI context [skip ci]"
git push
undefinedPattern 4: Git Hook for Local Freshness
场景4:本地Git钩子保持内容新鲜
bash
npx codesight --hookThis installs a post-commit hook that regenerates automatically after every commit.
.codesight/CODESIGHT.mdbash
npx codesight --hook该命令会安装一个post-commit钩子,每次提交后自动重新生成。
.codesight/CODESIGHT.mdPattern 5: Knowledge Mapping for Decision Records
场景5:架构决策记录的知识映射
bash
undefinedbash
undefinedMap ADRs and architecture docs
映射ADR和架构文档
npx codesight --mode knowledge ./docs/decisions
npx codesight --mode knowledge ./docs/decisions
Map full Obsidian vault
映射完整Obsidian vault
npx codesight --mode knowledge ~/vault
npx codesight --mode knowledge ~/vault
Outputs .codesight/KNOWLEDGE.md with:
输出.codesight/KNOWLEDGE.md,包含:
- Key decisions extracted from ADR files
- 从ADR文件提取的关键决策
- Open questions surfaced from notes
- 从笔记中发现的未解决问题
- Meeting notes indexed by date
- 按日期索引的会议记录
- Specs and PRDs cataloged
- 分类整理的规范和产品需求文档
undefinedundefinedConsuming the Output in AI Sessions
在AI会话中使用生成的内容
Loading Context in Claude Code (manual)
在Claude Code中手动加载上下文
Read .codesight/CODESIGHT.md for project context before answering questions.回答问题前先读取.codesight/CODESIGHT.md获取项目上下文。Loading Wiki at Session Start
会话启动时加载Wiki
Read .codesight/wiki/index.md first.
Then read the relevant article (e.g. .codesight/wiki/auth.md)
only when questions about that domain arise.首先读取.codesight/wiki/index.md。
只有当问题涉及对应领域时,再读取相关文档(例如.codesight/wiki/auth.md)。Loading Combined Context
加载组合上下文
Read .codesight/CODESIGHT.md for code structure and
.codesight/KNOWLEDGE.md for architectural decisions.读取.codesight/CODESIGHT.md了解代码结构,读取.codesight/KNOWLEDGE.md了解架构决策。Token Savings Reference
Token节省参考
| Approach | Tokens per session | Savings vs baseline |
|---|---|---|
| Manual file exploration | 26K–47K | baseline |
| 3K–5K | 7x–12x |
| ~200 + ~300/question | 60x–130x |
Real benchmark results from production codebases:
| Project | Stack | Files | Output Tokens | Exploration Tokens | Savings |
|---|---|---|---|---|---|
| SaaS A | Hono + Drizzle | 138 | 3,936 | 46,020 | 11.7x |
| SaaS B | Hono + Drizzle (monorepo) | 53 | 3,629 | 26,130 | 7.2x |
| SaaS C | FastAPI + MongoDB | 40 | 4,162 | 47,450 | 11.4x |
| Rails app | Rails + ActiveRecord | 4,172 | 21,711 | 386,100 | 17.8x |
| Laravel app | Laravel + Eloquent | 3,896 | 30,739 | 493,285 | 16x |
| 方案 | 每次会话Token消耗 | 较基准的节省比例 |
|---|---|---|
| 手动探索文件 | 26K–47K | 基准 |
| 3K–5K | 7倍–12倍 |
| ~200 + ~300/每个问题 | 60倍–130倍 |
生产代码库的实测基准结果:
| 项目 | 技术栈 | 文件数 | 输出Token数 | 探索消耗Token数 | 节省比例 |
|---|---|---|---|---|---|
| SaaS A | Hono + Drizzle | 138 | 3,936 | 46,020 | 11.7倍 |
| SaaS B | Hono + Drizzle( monorepo) | 53 | 3,629 | 26,130 | 7.2倍 |
| SaaS C | FastAPI + MongoDB | 40 | 4,162 | 47,450 | 11.4倍 |
| Rails应用 | Rails + ActiveRecord | 4,172 | 21,711 | 386,100 | 17.8倍 |
| Laravel应用 | Laravel + Eloquent | 3,896 | 30,739 | 493,285 | 16倍 |
.codesight Directory Structure
.codesight 目录结构
.codesight/
CODESIGHT.md — main context map (commit this)
KNOWLEDGE.md — knowledge/decision map (commit this)
wiki/
index.md — wiki catalog (commit this)
overview.md
auth.md
database.md
payments.md
users.md
ui.md
log.mdAdd to git to persist context across sessions and team members. The wiki survives session restarts — every new conversation starts with full codebase knowledge from the first message.
.codesight/.codesight/
CODESIGHT.md — 主上下文映射(建议提交到Git)
KNOWLEDGE.md — 知识/决策映射(建议提交到Git)
wiki/
index.md — Wiki目录(建议提交到Git)
overview.md
auth.md
database.md
payments.md
users.md
ui.md
log.md将添加到Git中,可在会话和团队成员之间同步上下文。Wiki内容会在会话重启后保留 — 每次新对话从第一条消息开始就具备完整的代码库知识。
.codesight/Troubleshooting
故障排查
Routes not detected:
- Ensure you're running from the project root (where or equivalent lives)
package.json - TypeScript projects get full AST parsing; other languages use regex — check that route files follow standard framework conventions
- For Python FastAPI, ensure router files use standard /
@app.get()decorators@router.post()
Models showing 0 for MongoDB:
- This is correct behavior — codesight parses SQL ORM declarations. MongoDB collections without Mongoose schemas won't appear. Define Mongoose schemas explicitly to get model detection.
Wiki articles missing:
- Run first to generate the wiki directory
npx codesight --wiki - Use MCP tool or check
codesight_lint_wikifor generation errors.codesight/wiki/log.md
Large monorepos (10K+ files) are slow:
- Add a file (same syntax as
.codesightignore) to exclude build artifacts, generated files, and.gitignoresubdirectoriesnode_modules - Typical scan time: 186ms–890ms for projects under 5K files
MCP server not connecting:
- Verify Node.js >= 18:
node --version - Check in MCP config points to the actual project root
cwd - Run manually first to confirm it starts without errors
npx codesight --mcp
--init- Back up existing files before running on a project with custom AI instructions
--init - Generated files are additive starting points — merge with your existing content manually
路由未检测到:
- 确保你在项目根目录运行命令(即或等效文件所在目录)
package.json - TypeScript项目支持完整AST解析;其他语言使用正则匹配 — 请确保路由文件遵循标准框架约定
- Python FastAPI项目请确保路由文件使用标准的/
@app.get()装饰器@router.post()
MongoDB模型显示为0:
- 这是正常行为 — codesight仅解析SQL ORM声明。没有Mongoose Schema的MongoDB集合不会被检测到。显式定义Mongoose Schema即可实现模型检测。
Wiki文档缺失:
- 先运行生成Wiki目录
npx codesight --wiki - 使用MCP工具或查看
codesight_lint_wiki排查生成错误.codesight/wiki/log.md
大型Monorepo(10K+文件)扫描缓慢:
- 添加文件(语法与
.codesightignore一致)排除构建产物、生成文件和.gitignore子目录node_modules - 典型扫描速度:5K文件以下的项目耗时186ms–890ms
MCP服务器连接失败:
- 确认Node.js版本 >= 18:
node --version - 检查MCP配置中的是否指向实际项目根目录
cwd - 先手动运行确认可以正常启动无报错
npx codesight --mcp
--init- 如果你项目有自定义AI指令,运行前先备份现有文件
--init - 生成的文件是增量的起点 — 请手动与你现有内容合并