بنقرة واحدة
grep-and-read
Find and read multiple files in one operation (50-70% faster for exploration)
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Find and read multiple files in one operation (50-70% faster for exploration)
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
| name | grep-and-read |
| description | Find and read multiple files in one operation (50-70% faster for exploration) |
| allowed-tools | Grep, Read, Bash |
Purpose: Search for pattern and read all matching files in a single coordinated operation, eliminating sequential round-trips.
Performance: 50-70% time savings, 4000-8000 token savings compared to sequential Grep -> Read -> Read -> Read pattern.
When to Use:
INEFFICIENT PATTERN (4 messages, 9-12 seconds):
Message 1: Grep "FormattingRule" -> returns 5 files
[Wait for response ~2.5s]
Message 2: Read src/main/java/.../FormattingRule.java
[Wait for response ~2.5s]
Message 3: Read src/test/java/.../FormattingRuleTest.java
[Wait for response ~2.5s]
Message 4: Read docs/architecture.md
[Wait for response ~2.5s]
-> Impact: 4 round-trips = ~10 seconds, ~12,000 tokens
-> Wasted: 3 avoidable round-trips
EFFICIENT PATTERN (1 message, 3-4 seconds):
Message 1: Skill grep-and-read pattern="FormattingRule" max_files=5
- Grep finds matches
- Read all matching files in parallel
- Return consolidated output
[Wait for response ~3.5s]
-> Impact: 1 round-trip = ~3.5 seconds, ~4,000 tokens
-> Saved: 3 round-trips = 6.5 seconds (65% faster), 8,000 tokens
| Parameter | Required | Default | Description |
|---|---|---|---|
pattern | Yes | - | Grep pattern to search for (regex supported) |
path | No | . | Directory to search in |
glob | No | - | File type filter (e.g., ".java", ".md") |
max_files | No | 5 | Maximum number of files to read |
context_lines | No | 100 | Lines to read per file (0 = all) |
case_sensitive | No | true | Case-sensitive search |
Use Grep tool to find all files containing the pattern:
# Search for pattern with optional filters
Grep: pattern="{pattern}"
path="{path}"
glob="{glob}"
output_mode="files_with_matches"
-i={!case_sensitive}
Example:
Grep: pattern="FormattingRule"
path="/path/to/project"
glob="*.java"
output_mode="files_with_matches"
Output: List of file paths
src/main/java/io/github/cowwoc/styler/formatter/FormattingRule.java
src/main/java/io/github/cowwoc/styler/formatter/FormattingRuleImpl.java
src/test/java/io/github/cowwoc/styler/formatter/FormattingRuleTest.java
Read all found files in a single message using multiple Read tool calls:
# Parallel read invocations in one message
Read: /path/to/project/src/main/java/.../FormattingRule.java
Read: /path/to/project/src/main/java/.../FormattingRuleImpl.java
Read: /path/to/project/src/test/java/.../FormattingRuleTest.java
If max_files exceeded: Show first N files, report total found If context_lines limited: Read first N lines of each file
Provide summary and consolidated output:
===============================================================
GREP AND READ SUMMARY
===============================================================
Pattern: FormattingRule
Files Found: 3
Files Read: 3
Total Size: ~15KB
Time Saved: ~6.5 seconds (vs sequential)
Tokens Saved: ~8,000 tokens
===============================================================
FILES READ:
---------------------------------------------------------------
FILE 1: src/main/java/.../FormattingRule.java
---------------------------------------------------------------
[file contents...]
---------------------------------------------------------------
FILE 2: src/main/java/.../FormattingRuleImpl.java
---------------------------------------------------------------
[file contents...]
---------------------------------------------------------------
FILE 3: src/test/java/.../FormattingRuleTest.java
---------------------------------------------------------------
[file contents...]
Goal: Understand how "FormattingRule" is implemented
Command:
Skill: grep-and-read
pattern="FormattingRule"
path="/path/to/project"
glob="*.java"
max_files=5
Benefit: Get complete picture of implementation in one round-trip
Goal: Find all files handling "ValidationException"
Command:
Skill: grep-and-read
pattern="ValidationException"
path="/path/to/project/src"
max_files=10
context_lines=50
Benefit: See all error handling patterns without multiple reads
Goal: Find all documentation mentioning "error handling"
Command:
Skill: grep-and-read
pattern="error handling"
path="/path/to/project/docs"
glob="*.md"
case_sensitive=false
context_lines=0
Benefit: Read all relevant docs in one operation
Goal: Find all tests for "Formatter" classes
Command:
Skill: grep-and-read
pattern="class.*Formatter.*Test"
path="/path/to/project/src/test"
glob="*Test.java"
max_files=8
Benefit: See complete test coverage at once
Problem: Pattern matches 50+ files
Solution:
max_files onlyOutput:
Warning: Pattern matched 53 files
Reading first 5 files (use max_files parameter to adjust)
Suggestion: Refine pattern or add glob filter for more targeted search
Problem: Files exceed context window
Solution:
context_lines parameter to limit outputOutput:
File: FormattingRule.java
Total lines: 1500
Read lines: 100 (first 100)
[... file contents ...]
[... truncated: showing 100 of 1500 lines ...]
Problem: Pattern doesn't match any files
Solution:
Output:
No files found matching pattern: "FooBar"
Search path: /path/to/project
Suggestions:
- Try case-insensitive search (case_sensitive=false)
- Broaden pattern (use wildcards)
- Check search path is correct
| Approach | Messages | Time | Tokens | Savings |
|---|---|---|---|---|
| Sequential (Grep + 5 Reads) | 6 | ~15s | ~18,000 | Baseline |
| grep-and-read Skill | 1 | ~4s | ~6,000 | 73% time, 67% tokens |
| Approach | Messages | Time | Tokens | Savings |
|---|---|---|---|---|
| Sequential (Grep + 3 Reads) | 4 | ~10s | ~12,000 | Baseline |
| grep-and-read Skill | 1 | ~3s | ~4,000 | 70% time, 67% tokens |
Use Grep alone when:
output_mode="files_with_matches")output_mode="content" and -C flag)Use this skill when:
batch-read: Use when you KNOW which files to read
# You already know the files
batch-read: "error-handling" --type md --max-files 5
grep-and-read: Use when you need to FIND files first
# You need to discover the files
grep-and-read: pattern="error handling" glob="*.md"
Grep (content mode): Use for seeing match context
# See lines around matches
Grep: pattern="FormattingRule" output_mode="content" -C=3
grep-and-read: Use for reading entire matching files
# Read complete files
grep-and-read: pattern="FormattingRule" max_files=5
Related Skills:
Related Tools:
Guide for writing clear, descriptive commit messages
Merge task branch to base branch with linear history (works from task worktree)
MANDATORY: Use instead of `git rebase` - provides automatic backup and conflict recovery
MANDATORY: Use instead of `git rebase -i` for squashing - unified commit messages
Analyze mistakes with conversation length as potential cause (CAT-specific)
Run scheduled retrospective analysis, derive action items, and track effectiveness