search-first
affaan-m/ECC
在编写自定义代码之前,通过调用研究代理来调研现有的工具、库和模式。
...展开全部/search-first — 先研究,再编码
将“在实现之前先寻找现有解决方案”的工作流程系统化。
触发条件
在以下情况下使用此技能:
- 开始开发新功能,且该功能很可能已有现成解决方案时
- 添加依赖项或集成
- 用户要求“添加 X 功能”,而你正准备编写代码时
- 在创建新的实用程序、辅助函数或抽象类之前
工作流程
┌─────────────────────────────────────────────┐
│ 0. TOOL AVAILABILITY PREFLIGHT │
│ Check search channels before relying on │
│ them; report skipped channels honestly │
├─────────────────────────────────────────────┤
│ 1. NEED ANALYSIS │
│ Define what functionality is needed │
│ Identify language/framework constraints │
├─────────────────────────────────────────────┤
│ 2. PARALLEL SEARCH (researcher agent) │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ npm / │ │ MCP / │ │ GitHub / │ │
│ │ PyPI │ │ Skills │ │ Web │ │
│ └──────────┘ └──────────┘ └──────────┘ │
├─────────────────────────────────────────────┤
│ 3. EVALUATE │
│ Score candidates (functionality, maint, │
│ community, docs, license, deps) │
├─────────────────────────────────────────────┤
│ 4. DECIDE │
│ ┌─────────┐ ┌──────────┐ ┌─────────┐ │
│ │ Adopt │ │ Extend │ │ Build │ │
│ │ as-is │ │ /Wrap │ │ Custom │ │
│ └─────────┘ └──────────┘ └─────────┘ │
├─────────────────────────────────────────────┤
│ 5. IMPLEMENT │
│ Install package / Configure MCP / │
│ Write minimal custom code │
└─────────────────────────────────────────────┘
决策矩阵
| 信号 | 操作 |
|---|---|
| 完全匹配、维护良好、MIT/Apache | 采用——直接安装并使用 |
| 部分匹配,基础良好 | 扩展 — 安装 + 编写轻量级封装层 |
| 多个弱匹配 | 组合——将2-3个小型软件包整合 |
| 未找到合适方案 | 构建——编写自定义代码,但需基于研究结果 |
使用方法
步骤 0:工具可用性预检
这是代理指南,并非可执行的设置脚本。请仅检查 与您当前任务和项目相关的渠道。
| 通道 | 检查项 | 若缺失 |
|---|---|---|
| 仓库搜索 | rg --files 和目标 rg 查询 |
说明仅检查了可见文件 |
| 软件包注册表 | npm --version, python -m pip --version或项目包管理器 |
使用 web/docs 搜索,并避免声称覆盖了注册表 |
| GitHub CLI | gh auth status |
仅使用公开的 Web 版本或本地 Git 历史记录 |
| MCP/文档工具 | 可用工具列表或本地 MCP 配置 | 回退到官方文档/网页搜索 |
| 技能目录 | ls ~/.claude/skills ~/.codex/skills (如适用) |
假设没有本地技能目录 |
快速模式(内联)
在编写实用程序或添加功能之前,请在脑海中思考:
- 仓库中是否已有此功能? →
rg先检查相关模块/测试 - 这是常见问题吗?→ 在 npm/PyPI 上搜索
- 是否有相应的 MCP?→ 检查
~/.claude/settings.json并搜索 - 是否有相关技能?→ 检查
~/.claude/skills/ - 是否有 GitHub 上的实现/模板?→ 在编写全新代码前,先在 GitHub 上搜索维护良好的开源代码
完整模式(代理)
对于非简单功能,请启动研究员代理:
Agent(subagent_type="general-purpose", prompt="
Research existing tools for: [DESCRIPTION]
Language/framework: [LANG]
Constraints: [ANY]
Search: npm/PyPI, MCP servers, Claude Code skills, GitHub
Return: Structured comparison with recommendation
")
较早版本的 Claude Code 文档可能将此称为 Task(...);请使用当前由活动框架提供的代理/子代理
工具名称。
按类别搜索快捷方式
开发工具
- 代码检查 →
eslint,ruff,textlint,markdownlint - 格式化 →
prettier,black,gofmt - 测试 →
jest,pytest,go test - 提交前检查 →
husky,lint-staged,pre-commit
AI/LLM 集成
- Claude SDK → 请访问Context7获取最新文档
- 提示词管理 → 检查 MCP 服务器
- 文档处理 →
unstructured,pdfplumber,mammoth
数据与API
- HTTP 客户端 →
httpx(Python),ky/undici(Node) - 验证 →
zod(TS),pydantic(Python) - 数据库 → 首先检查 MCP 服务器
内容与发布
- Markdown 处理 →
remark,unified,markdown-it - 图片优化 →
sharp,imagemin
集成点
使用规划器代理
规划师应在第1阶段(架构审查)之前调用研究员:
- 研究人员确定可用的工具
- 规划师将其纳入实施计划
- 避免在计划中“重复造轮子”
与架构师代理配合
架构师应就以下事项咨询研究员:
- 技术栈决策
- 集成模式的探索
- 现有参考架构
结合迭代检索技能
将其结合以实现渐进式探索:
- 第一轮:广泛搜索(npm、PyPI、MCP)
- 第 2 轮:详细评估顶级候选方案
- 第三轮:测试与项目约束条件的兼容性
示例
示例 1:“添加死链检测”
Need: Check markdown files for broken links
Search: npm "markdown dead link checker"
Found: textlint-rule-no-dead-link (score: 9/10)
Action: ADOPT — npm install textlint-rule-no-dead-link
Result: Zero custom code, battle-tested solution
示例 2:“添加 HTTP 客户端封装层”
Need: Resilient HTTP client with retries and timeout handling
Search: npm "http client retry", PyPI "httpx retry"
Found: got (Node) with retry plugin, httpx (Python) with built-in retry
Action: ADOPT — use got/httpx directly with retry config
Result: Zero custom code, production-proven libraries
示例 3:“添加配置文件代码检查工具”
Need: Validate project config files against a schema
Search: npm "config linter schema", "json schema validator cli"
Found: ajv-cli (score: 8/10)
Action: ADOPT + EXTEND — install ajv-cli, write project-specific schema
Result: 1 package + 1 schema file, no custom validation logic
反模式
- 直接跳到代码:在未检查是否已有现成工具的情况下编写实用程序
- 忽视 MCP:未检查 MCP 服务器是否已提供该功能
- 静默跳过:当搜索通道不可用时,报告“未找到任何内容”
- 过度定制:对库进行过度封装,以致丧失其原有优势
- 依赖膨胀:为一个微小功能安装庞大的软件包
---
name: search-first
description: Research existing tools, libraries, and patterns before writing custom code by invoking a researcher agent.
---
# /search-first — Research Before You Code
Systematizes the "search for existing solutions before implementing" workflow.
## Trigger
Use this skill when:
- Starting a new feature that likely has existing solutions
- Adding a dependency or integration
- The user asks "add X functionality" and you're about to write code
- Before creating a new utility, helper, or abstraction
## Workflow
```
┌─────────────────────────────────────────────┐
│ 0. TOOL AVAILABILITY PREFLIGHT │
│ Check search channels before relying on │
│ them; report skipped channels honestly │
├─────────────────────────────────────────────┤
│ 1. NEED ANALYSIS │
│ Define what functionality is needed │
│ Identify language/framework constraints │
├─────────────────────────────────────────────┤
│ 2. PARALLEL SEARCH (researcher agent) │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ npm / │ │ MCP / │ │ GitHub / │ │
│ │ PyPI │ │ Skills │ │ Web │ │
│ └──────────┘ └──────────┘ └──────────┘ │
├─────────────────────────────────────────────┤
│ 3. EVALUATE │
│ Score candidates (functionality, maint, │
│ community, docs, license, deps) │
├─────────────────────────────────────────────┤
│ 4. DECIDE │
│ ┌─────────┐ ┌──────────┐ ┌─────────┐ │
│ │ Adopt │ │ Extend │ │ Build │ │
│ │ as-is │ │ /Wrap │ │ Custom │ │
│ └─────────┘ └──────────┘ └─────────┘ │
├─────────────────────────────────────────────┤
│ 5. IMPLEMENT │
│ Install package / Configure MCP / │
│ Write minimal custom code │
└─────────────────────────────────────────────┘
```
## Decision Matrix
| Signal | Action |
|--------|--------|
| Exact match, well-maintained, MIT/Apache | **Adopt** — install and use directly |
| Partial match, good foundation | **Extend** — install + write thin wrapper |
| Multiple weak matches | **Compose** — combine 2-3 small packages |
| Nothing suitable found | **Build** — write custom, but informed by research |
## How to Use
### Step 0: Tool Availability Preflight
This is agent guidance, not an executable setup script. Check only the channels
that are relevant to the task and project in front of you.
| Channel | Check | If missing |
|---------|-------|------------|
| Repository search | `rg --files` and targeted `rg` queries | State that only visible files were inspected |
| Package registry | `npm --version`, `python -m pip --version`, or project package manager | Use web/docs search and avoid claiming registry coverage |
| GitHub CLI | `gh auth status` | Use public web or local git history only |
| MCP/docs tools | Available tool list or local MCP config | Fall back to official docs/web search |
| Skills directory | `ls ~/.claude/skills ~/.codex/skills` where applicable | Say no local skill catalog was available |
### Quick Mode (inline)
Before writing a utility or adding functionality, mentally run through:
0. Does this already exist in the repo? → `rg` through relevant modules/tests first
1. Is this a common problem? → Search npm/PyPI
2. Is there an MCP for this? → Check `~/.claude/settings.json` and search
3. Is there a skill for this? → Check `~/.claude/skills/`
4. Is there a GitHub implementation/template? → Run GitHub code search for maintained OSS before writing net-new code
### Full Mode (agent)
For non-trivial functionality, launch the researcher agent:
```
Agent(subagent_type="general-purpose", prompt="
Research existing tools for: [DESCRIPTION]
Language/framework: [LANG]
Constraints: [ANY]
Search: npm/PyPI, MCP servers, Claude Code skills, GitHub
Return: Structured comparison with recommendation
")
```
Older Claude Code docs may call this `Task(...)`; use the current agent/subagent
tool name exposed by the active harness.
## Search Shortcuts by Category
### Development Tooling
- Linting → `eslint`, `ruff`, `textlint`, `markdownlint`
- Formatting → `prettier`, `black`, `gofmt`
- Testing → `jest`, `pytest`, `go test`
- Pre-commit → `husky`, `lint-staged`, `pre-commit`
### AI/LLM Integration
- Claude SDK → Context7 for latest docs
- Prompt management → Check MCP servers
- Document processing → `unstructured`, `pdfplumber`, `mammoth`
### Data & APIs
- HTTP clients → `httpx` (Python), `ky`/`undici` (Node)
- Validation → `zod` (TS), `pydantic` (Python)
- Database → Check for MCP servers first
### Content & Publishing
- Markdown processing → `remark`, `unified`, `markdown-it`
- Image optimization → `sharp`, `imagemin`
## Integration Points
### With planner agent
The planner should invoke researcher before Phase 1 (Architecture Review):
- Researcher identifies available tools
- Planner incorporates them into the implementation plan
- Avoids "reinventing the wheel" in the plan
### With architect agent
The architect should consult researcher for:
- Technology stack decisions
- Integration pattern discovery
- Existing reference architectures
### With iterative-retrieval skill
Combine for progressive discovery:
- Cycle 1: Broad search (npm, PyPI, MCP)
- Cycle 2: Evaluate top candidates in detail
- Cycle 3: Test compatibility with project constraints
## Examples
### Example 1: "Add dead link checking"
```
Need: Check markdown files for broken links
Search: npm "markdown dead link checker"
Found: textlint-rule-no-dead-link (score: 9/10)
Action: ADOPT — npm install textlint-rule-no-dead-link
Result: Zero custom code, battle-tested solution
```
### Example 2: "Add HTTP client wrapper"
```
Need: Resilient HTTP client with retries and timeout handling
Search: npm "http client retry", PyPI "httpx retry"
Found: got (Node) with retry plugin, httpx (Python) with built-in retry
Action: ADOPT — use got/httpx directly with retry config
Result: Zero custom code, production-proven libraries
```
### Example 3: "Add config file linter"
```
Need: Validate project config files against a schema
Search: npm "config linter schema", "json schema validator cli"
Found: ajv-cli (score: 8/10)
Action: ADOPT + EXTEND — install ajv-cli, write project-specific schema
Result: 1 package + 1 schema file, no custom validation logic
```
## Anti-Patterns
- **Jumping to code**: Writing a utility without checking if one exists
- **Ignoring MCP**: Not checking if an MCP server already provides the capability
- **Silent skipping**: Reporting "nothing found" when a search channel was unavailable
- **Over-customizing**: Wrapping a library so heavily it loses its benefits
- **Dependency bloat**: Installing a massive package for one small feature
所有文件
1 个文件安装 search-first
下载技能文件并将其解压到 .claude/skills/ 目录中。
下载ZIP克隆仓库并复制技能文件到您的项目中。
git clone https://github.com/affaan-m/ECC/tree/main/skills/search-first # Copy SKILL.md to your .claude/skills/ directory
复制





首页
