Agent安装
- 作者仓库星标 365
- 作者更新于 实时读取
- 作者仓库 ctx
- 领域
- 文档
- 兼容 Agent
-
- Claude Code
- Cursor
- Cline
- Codex
- Windsurf
- Gemini CLI
- +20
- 信任分
- 88 / 100 · 社区维护
- 作者 / 版本 / 许可
- @stevesolun · 未声明 license
- Token 消耗评级
- 低消耗
- 接入复杂程度
- 需手动接入
- 是否需要外部 API Key
- 不需要
- 兼容的系统
- Docker
- 底层运行要求
- Docker
- 文件与系统权限
-
- 只读
- 允许写入 / 修改
- Shell 执行
- 网络行为
- 仅限本地
- 安装命令数
- 26 条
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
---
name: skill-router
description: Repo-aware recommendation manager for ctx. Scans the active repository, identifies stack and wor…
category: 文档
runtime: Docker
---
# skill-router 输出预览
## PART A: 任务判断
- 适用问题:PRD、RFC、README、项目说明或知识库整理。
- 输入要求:目标材料、限制条件、期望输出和验收方式。
- 证据边界:围绕“Scope / Problem / Architecture”读取原文规则,不把推断写成作者承诺。
## PART B: 执行结果
- **01** 任务判断:确认你的需求是否属于PRD、RFC、README、项目说明或知识库整理,并标出输入、限制和预期结果。
- **02** 执行计划:优先按“Scope / Problem / Architecture”拆成步骤,说明每一步会读取什么、修改什么、产出什么。
- **03** 交付结果:给出可复制的命令、文件改动、检查清单或内容草稿,并说明如何继续迭代。
- **04** 风险边界:结合 读取文件、写入/修改文件、执行终端命令、主要在本地完成、通常不需要额外 API Key 给出执行前确认项。
## Running Rules
- 读取文件、写入/修改文件、执行终端命令;主要在本地完成;通常不需要额外 API Key。
- 先小样例验证,再放大到真实任务。
- 交付时同时给结果、检查口径和下一步迭代建议。 原文没有稳定的斜杠命令要求。安装验证后通常全局生效,直接在对话里点名这个 Skill 并描述任务即可。
告诉 Agent 目标文件或材料、期望结果、不可改范围、是否允许联网或执行命令。本 Skill 的权限画像是:读取文件、写入/修改文件、执行终端命令。
先用一个小任务确认它会围绕“Scope / Problem / Architecture”工作;涉及文件或命令时,先看 diff、日志、预览或测试结果。
检查最终产物是否包含明确结果、必要证据和下一步动作;如果输出泛泛而谈,就补充输入、边界和验收标准后重跑。
---
name: skill-router
description: Repo-aware recommendation manager for ctx. Scans the active repository, identifies stack and wor…
category: 文档
source: stevesolun/ctx
---
# skill-router
## 什么时候使用
- 把项目文档方向的常用动作沉淀成 Agent 可调用的技能 适合处理README、PRD、RFC、教程和知识库文档,核心价值是把输入、判断、执行、验证和交付边界固定下来,避免 Agent 泛泛回答。 把任务拆成可执行、可检查、可继续迭代的…
- 面向PRD、RFC、README、项目说明或知识库整理,优先处理能明确输入、步骤和验收标准的工作。
## 需要提供什么
- 目标材料、目录范围、期望结果和不可改动内容。
- 是否允许联网、执行命令、读写文件或调用外部服务。
## 执行规则
- 围绕「Scope / Problem / Architecture」组织步骤,不把推断写成作者事实。
- 读取文件、写入/修改文件、执行终端命令;主要在本地完成;通常不需要额外 API Key。
- 先跑小样例,确认结果可检查后再扩大任务范围。
## 输出要求
- 给出最终产物、关键证据、验证方式和下一步动作。
- 信息不足时标记 unknown,不编造命令、平台或依赖。 作者原文负责流程事实;仓库文件负责来源和命令;流狐只补充适用场景、限制和质量判断。
skill "skill-router" {
输入层 -> 用户目标 + 目标文件 + 禁止范围 + 验收标准
上下文层 -> Scope / Problem / Architecture
规则层 -> SKILL.md 触发条件 / 执行顺序 / 输出格式
运行层 -> Docker | 读取文件、写入/修改文件、执行终端命令 | 主要在本地完成
安全层 -> 通常不需要额外 API Key + 小任务验证 + diff / 日志复核
输出层 -> 可复制结果 + 检查清单 + 下一步迭代
} Skill Router
Scan a repo. Know what the current work needs. Recommend only that. Keep the wiki and graph as the durable catalog behind the decision.
Scope
The router manages runtime recommendations for:
- skills
- agents
- MCP servers
Harnesses are separate catalog entities. They are recommended when a user wants to run ctx with a non-Claude-Code host, local model, or API model. Once attached, the harness calls the same skills/agents/MCP recommendation engine.
Problem
Every loaded helper costs tokens, attention, and operational surface area. Most sessions need a small top-scored bundle from the shipped graph, not every entity ctx knows about. Loading too much:
- wastes context on irrelevant instructions,
- causes misfires when a helper matches the wrong task,
- slows the agent loop, and
- creates conflicting instructions.
Architecture
ctx/
|-- src/scan_repo.py # Repo scanner -> stack profile
|-- src/ctx/core/resolve/resolve_skills.py # Profile -> load/unload manifest
|-- src/ctx/core/resolve/recommendations.py # Shared scoring/ranking engine
|-- src/ctx/adapters/ # Claude Code hooks + generic tools
|-- src/harness_install.py # Custom-model harness install flow
`-- graph/wiki-graph-runtime.tar.gz # Shipped graph/wiki runtime
The router has three halves:
- Scanner - analyzes a repo and produces stack/task evidence.
- Resolver - scores graph/wiki entities and emits a capped manifest.
- Wiki/graph - persistent catalog of entities, usage, quality, and links.
Startup Flow
- Read the shipped graph/wiki metadata and local user overrides.
- Run
ctx-scan-repo --repo . --recommendfor the active repo. - Resolve a load/unload manifest with the shared recommendation engine.
- Present changes with reasons and require confirmation unless the user enabled automatic mode.
- Record usage/quality changes after the user accepts or rejects suggestions.
Scanner
The scanner reads repo structure and files to produce a stack profile. Detection is evidence-based: every claim should map to a file, dependency, config value, or import pattern.
Detection Categories
- Languages - file extensions, shebangs, lock files.
- Frameworks and libraries - package manifests, imports, config files.
- Infrastructure and DevOps - Docker, CI/CD, IaC, cloud, Kubernetes.
- Data and storage - databases, migrations, queues, pipelines.
- Documentation and content - MkDocs, Docusaurus, Sphinx, API specs.
- Testing and quality - pytest, Jest, Playwright, Ruff, mypy, TypeScript.
- AI and agent tooling - MCP configs, LangGraph, CrewAI, prompt dirs, model config names.
- Build and package - package managers, build tools, monorepos.
Scanning Rules
- Start with filenames and config files. Read source only when needed to disambiguate.
- Do not include speculative signals below the configured confidence floor.
- Skip generated/vendor directories such as
.git,node_modules,__pycache__,venv, and.venv. - Keep initial scans bounded for large repos.
- Redact secret values; only record secret/key names as evidence.
Resolver
The resolver produces a manifest containing the exact helper set to load or unload.
{
"generated_at": "ISO-8601",
"repo_path": "/absolute/path",
"profile_hash": "sha256 of stack profile",
"load": [
{
"name": "fastapi",
"type": "skill",
"reason": "FastAPI detected in pyproject.toml dependencies",
"score": 0.94
}
],
"unload": [
{
"name": "react",
"type": "skill",
"reason": "No active frontend signal in the current repo window"
}
],
"suggestions": [
{
"name": "github",
"type": "mcp",
"reason": ".github/workflows exists and the repo uses GitHub Actions",
"install_command": "ctx-mcp-add ..."
}
],
"warnings": []
}
Ranking Signals
Candidates can be scored by:
- tag/category/subcategory match
- semantic similarity edge weight
- direct wiki links
- source overlap
- type affinity
- usage score
- quality/security score
- user overrides (
always_load,never_load) - configured caps and minimum score gates
Recommendations are capped. ctx should not recommend at all costs; below-threshold candidates should be withheld and the gap should be explained.
Wiki And Graph Contract
The wiki follows a Karpathy-style durable memory pattern: schema, purpose, index, log, lint, review items, and entity pages that are machine-readable.
llm-wiki/
|-- SCHEMA.md
|-- index.md
|-- log.md
|-- raw/
| |-- scans/
| `-- external-catalogs/
|-- entities/
| |-- skills/
| |-- agents/
| |-- mcp-servers/
| `-- harnesses/
|-- concepts/
|-- comparisons/
`-- queries/
Entity pages use YAML frontmatter with at least:
title: Entity Name
type: skill | agent | mcp-server | harness | external-catalog
status: installed | available | deprecated | broken
tags: []
source: local | shipped | github | curated
source_url: ""
path: ""
quality_score: null
usage_score: 0
last_used: null
always_load: false
never_load: false
Entity Sources
Entity sources include shipped skill/MCP/harness sources, GitHub
entity repositories, and local user assets. The public reference page is
marketplace-registry.md, kept under that filename
for backwards-compatible links.
Source rules:
- Search the shipped graph/wiki first.
- Use additional sources only when the local graph is missing or stale.
- Deduplicate before adding.
- If an entity exists, emit an update review instead of replacing it.
- Run security checks before promotion.
- Rebuild and validate graph/wiki artifacts before shipping.
Micro-Skill Gate
Every added or updated skill must pass the configured line-count gate before it
is packed into the shipped wiki. The default threshold is 180 lines, read from
ctx config. Skills above the threshold are converted into a short orchestrator
plus staged reference files. Local .original backups may be preserved for
traceability, but packaged runtime archives must omit those backups.
Core Operations
Full Scan
Triggers: repo open, repo switch, ctx-scan-repo --repo . --recommend, or explicit user
request.
- Read wiki orientation and local overrides.
- Scan the target repo.
- Save the scan result.
- Resolve load/unload recommendations.
- Present reasons, scores, and install/update commands.
- Apply only after confirmation unless configured otherwise.
- Record usage and decisions.
Incremental Scan
Triggers: changed config files, new dependencies, new MCP config, new tests, new infrastructure files, or user task change.
If a helper is no longer useful, ctx should suggest unloading it and ask for confirmation. If the user asks to skip unload prompts, ctx should respect that preference.
Manual Override
- "Always load the docker skill" -> set
always_load: true. - "Never load the react skill" -> set
never_load: true. - "Load the terraform skill for this session" -> temporary load.
- "What is loaded?" -> show current manifest with reasons.
Discovery
When the user asks what exists for a task:
- Search graph/wiki entity pages by tags and text.
- Use
find-skillsand configured sources for remote freshness when needed. - Show status, score, source, and risk notes.
- Suggest install/update commands, not silent installs.
- Log the query.
Maintenance Checks
- Stale installed helpers - used rarely or not used recently.
- Ghost helpers - installed status but missing local path.
- Orphan local helpers - present locally but missing entity page.
- Skill index freshness - shipped skill snapshot older than policy.
- Conflicts - overlapping helpers both marked
always_load. - Usage cold spots - low usage/quality score candidates for unload review.
- Wiki lint - broken links, missing frontmatter, index drift.
Reporting
After a scan, report only actionable details:
Skill Router Report - repo-name
Scanned: YYYY-MM-DD HH:MM
Loaded:
1. fastapi skill - score 0.94 - pyproject.toml dependency
2. github MCP - score 0.91 - GitHub Actions workflows detected
Unload candidates:
1. react skill - no active frontend signal
Suggestions:
1. openapi-generator skill - OpenAPI spec found
Warnings:
None
Configuration
Router behavior is controlled by ctx config and user overrides. Important knobs:
recommendations:
max_total: 5
min_score: 0.85
micro_skills:
max_lines: 180
router:
auto_scan: true
auto_apply: false
ask_before_unload: true
Pitfalls
- Never load all helpers just in case.
- Never replace an existing entity without an update review.
- Never execute external repo scripts while cataloging.
- Never treat conversation history as the source of workflow state.
- Never ship graph/wiki artifacts before validation passes.
- Respect
never_loadand user rejection history.
先判断是否适合
作者设计意图
作者的方法与取舍
边界和复核