Skip to content

Commit e4ee77a

Browse files
authored
Merge pull request #281 from EveryInc/fix/research-agents-prefer-native-tools
fix: research agents to prefer native tools over shell
2 parents 350465e + b290690 commit e4ee77a

6 files changed

Lines changed: 37 additions & 19 deletions

File tree

docs/specs/codex.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ https://developers.openai.com/codex/mcp
4848
- `SKILL.md` uses YAML front matter and requires `name` and `description`. citeturn3view3turn3view4
4949
- Required fields are single-line with length limits (name ≤ 100 chars, description ≤ 500 chars). citeturn3view4
5050
- At startup, Codex loads only each skill’s name/description; full content is injected when invoked. citeturn3view3turn3view4
51-
- Skills can be repo-scoped in `.codex/skills/` or user-scoped in `~/.codex/skills/`. citeturn3view4
51+
- Skills can be repo-scoped in `.agents/skills/` and are discovered from the current working directory up to the repository root. User-scoped skills live in `~/.agents/skills/`. citeturn1view1turn1view4
52+
- Inference: some existing tooling and user setups still use `.codex/skills/` and `~/.codex/skills/` as legacy compatibility paths, but those locations are not documented in the current OpenAI Codex skills docs linked above.
53+
- Codex also supports admin-scoped skills in `/etc/codex/skills` plus built-in system skills bundled with Codex. citeturn1view4
5254
- Skills can be invoked explicitly using `/skills` or `$skill-name`. citeturn3view3
5355

5456
## MCP (Model Context Protocol)

plugins/compound-engineering/AGENTS.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,18 @@ This plugin is authored once, then converted for other agent platforms. Commands
9393
- [ ] When one skill refers to another skill, prefer semantic wording such as "load the `document-review` skill" rather than slash syntax.
9494
- [ ] Use slash syntax only when referring to an actual published command or workflow such as `/ce:work` or `/deepen-plan`.
9595

96+
### Tool Selection in Agents and Skills
97+
98+
Agents and skills that explore codebases must prefer native tools over shell commands.
99+
100+
Why: shell-heavy exploration causes avoidable permission prompts in sub-agent workflows; native file-search, content-search, and file-read tools avoid that.
101+
102+
- [ ] Never instruct agents to use `find`, `ls`, `cat`, `head`, `tail`, `grep`, `rg`, `wc`, or `tree` through a shell for routine file discovery, content search, or file reading
103+
- [ ] Describe tools by capability class with platform hints — e.g., "Use the native file-search/glob tool (e.g., Glob in Claude Code)" — not by Claude Code-specific tool names alone
104+
- [ ] When shell is the only option (e.g., `ast-grep`, `bundle show`, git commands), instruct one simple command at a time — no chaining (`&&`, `||`, `;`), pipes, or redirects
105+
- [ ] Do not encode shell recipes for routine exploration when native tools can do the job; encode intent and preferred tool classes instead
106+
- [ ] For shell-only workflows (e.g., `gh`, `git`, `bundle show`, project CLIs), explicit command examples are acceptable when they are simple, task-scoped, and not chained together
107+
96108
### Quick Validation Command
97109

98110
```bash

plugins/compound-engineering/agents/research/best-practices-researcher.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,12 @@ You are an expert technology researcher specializing in discovering, analyzing,
3030
Before going online, check if curated knowledge already exists in skills:
3131

3232
1. **Discover Available Skills**:
33-
- Use Glob to find all SKILL.md files: `**/**/SKILL.md` and `~/.claude/skills/**/SKILL.md`
34-
- Also check project-level skills: `.claude/skills/**/SKILL.md`
35-
- Read the skill descriptions to understand what each covers
33+
- Use the platform's native file-search/glob capability to find `SKILL.md` files in the active skill locations
34+
- For maximum compatibility, check project/workspace skill directories in `.claude/skills/**/SKILL.md`, `.codex/skills/**/SKILL.md`, and `.agents/skills/**/SKILL.md`
35+
- Also check user/home skill directories in `~/.claude/skills/**/SKILL.md`, `~/.codex/skills/**/SKILL.md`, and `~/.agents/skills/**/SKILL.md`
36+
- In Codex environments, `.agents/skills/` may be discovered from the current working directory upward to the repository root, not only from a single fixed repo root location
37+
- If the current environment provides an `AGENTS.md` skill inventory (as Codex often does), use that list as the initial discovery index, then open only the relevant `SKILL.md` files
38+
- Use the platform's native file-read capability to examine skill descriptions and understand what each covers
3639

3740
2. **Identify Relevant Skills**:
3841
Match the research topic to available skills. Common mappings:
@@ -123,4 +126,6 @@ Always cite your sources and indicate the authority level:
123126

124127
If you encounter conflicting advice, present the different viewpoints and explain the trade-offs.
125128

129+
**Tool Selection:** Use native file-search/glob (e.g., `Glob`), content-search (e.g., `Grep`), and file-read (e.g., `Read`) tools for repository exploration. Only use shell for commands with no native equivalent (e.g., `bundle show`), one command at a time.
130+
126131
Your research should be thorough but focused on practical application. The goal is to help users implement best practices confidently, not to overwhelm them with every possible approach.

plugins/compound-engineering/agents/research/framework-docs-researcher.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,6 @@ Structure your findings as:
103103
6. **Common Issues**: Known problems and their solutions
104104
7. **References**: Links to documentation, GitHub issues, and source files
105105

106+
**Tool Selection:** Use native file-search/glob (e.g., `Glob`), content-search (e.g., `Grep`), and file-read (e.g., `Read`) tools for repository exploration. Only use shell for commands with no native equivalent (e.g., `bundle show`), one command at a time.
107+
106108
Remember: You are the bridge between complex documentation and practical implementation. Your goal is to provide developers with exactly what they need to implement features correctly and efficiently, following established best practices for their specific framework versions.

plugins/compound-engineering/agents/research/git-history-analyzer.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,19 @@ assistant: "Let me use the git-history-analyzer agent to investigate the histori
2323

2424
You are a Git History Analyzer, an expert in archaeological analysis of code repositories. Your specialty is uncovering the hidden stories within git history, tracing code evolution, and identifying patterns that inform current development decisions.
2525

26+
**Tool Selection:** Use native file-search/glob (e.g., `Glob`), content-search (e.g., `Grep`), and file-read (e.g., `Read`) tools for all non-git exploration. Use shell only for git commands, one command per call.
27+
2628
Your core responsibilities:
2729

28-
1. **File Evolution Analysis**: For each file of interest, execute `git log --follow --oneline -20` to trace its recent history. Identify major refactorings, renames, and significant changes.
30+
1. **File Evolution Analysis**: Run `git log --follow --oneline -20 <file>` to trace recent history. Identify major refactorings, renames, and significant changes.
2931

30-
2. **Code Origin Tracing**: Use `git blame -w -C -C -C` to trace the origins of specific code sections, ignoring whitespace changes and following code movement across files.
32+
2. **Code Origin Tracing**: Run `git blame -w -C -C -C <file>` to trace the origins of specific code sections, ignoring whitespace changes and following code movement across files.
3133

32-
3. **Pattern Recognition**: Analyze commit messages using `git log --grep` to identify recurring themes, issue patterns, and development practices. Look for keywords like 'fix', 'bug', 'refactor', 'performance', etc.
34+
3. **Pattern Recognition**: Run `git log --grep=<keyword> --oneline` to identify recurring themes, issue patterns, and development practices.
3335

34-
4. **Contributor Mapping**: Execute `git shortlog -sn --` to identify key contributors and their relative involvement. Cross-reference with specific file changes to map expertise domains.
36+
4. **Contributor Mapping**: Run `git shortlog -sn -- <path>` to identify key contributors and their relative involvement.
3537

36-
5. **Historical Pattern Extraction**: Use `git log -S"pattern" --oneline` to find when specific code patterns were introduced or removed, understanding the context of their implementation.
38+
5. **Historical Pattern Extraction**: Run `git log -S"pattern" --oneline` to find when specific code patterns were introduced or removed.
3739

3840
Your analysis methodology:
3941
- Start with a broad view of file history before diving into specifics

plugins/compound-engineering/agents/research/repo-research-analyst.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ You are an expert repository research analyst specializing in understanding code
5656
- Analyze template structure and required fields
5757

5858
5. **Codebase Pattern Search**
59-
- Use `ast-grep` for syntax-aware pattern matching when available
60-
- Fall back to `rg` for text-based searches when appropriate
59+
- Use the native content-search tool for text and regex pattern searches
60+
- Use the native file-search/glob tool to discover files by name or extension
61+
- Use the native file-read tool to examine file contents
62+
- Use `ast-grep` via shell when syntax-aware pattern matching is needed
6163
- Identify common implementation patterns
6264
- Document naming conventions and code organization
6365

@@ -115,14 +117,7 @@ Structure your findings as:
115117
- Flag any contradictions or outdated information
116118
- Provide specific file paths and examples to support findings
117119

118-
**Search Strategies:**
119-
120-
Use the built-in tools for efficient searching:
121-
- **Grep tool**: For text/code pattern searches with regex support (uses ripgrep under the hood)
122-
- **Glob tool**: For file discovery by pattern (e.g., `**/*.md`, `**/CLAUDE.md`)
123-
- **Read tool**: For reading file contents once located
124-
- For AST-based code patterns: `ast-grep --lang ruby -p 'pattern'` or `ast-grep --lang typescript -p 'pattern'`
125-
- Check multiple variations of common file names
120+
**Tool Selection:** Use native file-search/glob (e.g., `Glob`), content-search (e.g., `Grep`), and file-read (e.g., `Read`) tools for repository exploration. Only use shell for commands with no native equivalent (e.g., `ast-grep`), one command at a time.
126121

127122
**Important Considerations:**
128123

0 commit comments

Comments
 (0)