本文へ移動
cccskills
無料GitHub で公開

file-search

Use when searching codebases (text, structural/AST, files by name, PDFs/archives, code stats) or building context before a task.

インストール方法を見る

含まれるファイル(11)

  • SKILL.md3.9 KB
  • evals/evals.json23.7 KB
  • references/ast-grep-patterns.md10.2 KB
  • references/code-metrics.md1.2 KB
  • references/enforcement-hook.md2.5 KB
  • references/fd-guide.md2.7 KB
  • references/remote-handoff.md1.8 KB
  • references/rga-guide.md2.0 KB
  • references/ripgrep-patterns.md9.4 KB
  • references/search-strategies.md3.0 KB
  • references/semgrep-patterns.md4.0 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

File Search Skill

Efficient CLI search tools for AI agents.

Tool Selection Guide

TaskUseInstead of
Search text in code filesrg (ripgrep)grep, grep -r
Find files by name/pathfdfind, ls -R
Structural/syntax-aware code searchsg (ast-grep)regex hacks
Apply rule packs (security/lint, taint)semgrepregex CI checks
Search PDFs, Office docs, archivesrga (ripgrep-all)manual extraction
Count lines of code by languagetokeicloc, wc -l
Code stats with complexity metricsscccloc, tokei

Decision flow: text → rg | structural → sg | rule packs → semgrep | filenames → fd | PDFs/archives → rga | LOC → tokei/scc

Quick Examples

rg 'def \w+\(' -t py src/          # rg: text search in Python files
rg -c 'TODO' -t js | wc -l         # rg: count first, then drill down
sg --pattern 'console.log($$$)' --rewrite 'logger.info($$$)' --lang js  # sg: structural replace
fd -g '*.test.ts' --changed-within 1d  # fd: -g for compound suffixes (NOT -e)
fd -g '*_test.go' -X rg 'func Test'   # fd+rg: find files, verify contents
rga 'quarterly revenue' docs/       # rga: search inside PDFs/archives
tokei --sort code                   # tokei: language stats
scc --wide                          # scc: complexity + COCOMO

Best Practices

  1. Start narrow. Specify types (-t, --lang, -e), scope dirs, count first (rg -c).
  2. Exclude noise (-g '!vendor/', fd -E node_modules).
  3. Batch independent queries. Union patterns with rg -e P1 -e P2 -e P3 (one walk), or issue distinct queries as parallel tool calls in one message — never sequential && chains.
  4. --json for programmatic processing.
  5. rg ≠ fd types. rg -t ts includes .tsx; fd -e ts does NOT. No -t tsx in rg.

See references/search-strategies.md.

Beyond Local Files

If local search finds nothing and context lives in issues/PRs/external docs — hand off (gh, Jira, WebFetch). Issue keys in comments signal this.

See references/remote-handoff.md.

References

TopicFile
rg flags, patterns, recipesreferences/ripgrep-patterns.md
ast-grep patterns by languagereferences/ast-grep-patterns.md
semgrep rules and taint modereferences/semgrep-patterns.md
fd flags, usage, fd+rg combosreferences/fd-guide.md
rga formats, usage, cachingreferences/rga-guide.md
tokei and scc usagereferences/code-metrics.md
PreToolUse nudge (ships with plugin)references/enforcement-hook.md
Search targeting strategiesreferences/search-strategies.md
Remote context handoff guidereferences/remote-handoff.md
Modern CLI tools comparison (legacy→modern, all domains)cli-tools SKILL.md#preferred-modern-tools

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

このスキルの問題を報告する