$npx -y skills add fusengine/agents --skill think-in-codeUse ONE Bash script instead of N sequential Read calls when analyzing multiple files, auditing codebase, finding all matches, scanning dependencies, counting lines, or listing files matching a pattern. Replaces wasteful multi-Read loops with compact shell pipelines.
| 1 | # Think-in-Code Skill |
| 2 | |
| 3 | ## Principle |
| 4 | |
| 5 | **1 Bash script = N Read calls avoided.** |
| 6 | |
| 7 | When you'd read 10 files sequentially to extract a summary, you waste tokens loading full contents into context. Instead: 1 shell pipeline returns the compact aggregated result. |
| 8 | |
| 9 | Heuristic: if your task is "for each file in set, compute/extract X, then aggregate" → write the script. Reserve Read for *targeted inspection* of a specific file you already know matters. |
| 10 | |
| 11 | ## 5 Runnable Patterns |
| 12 | |
| 13 | ### 1. File size audit (> 100 lines violations) |
| 14 | |
| 15 | ```bash |
| 16 | find . -type f \( -name "*.ts" -o -name "*.tsx" -o -name "*.py" -o -name "*.php" \) \ |
| 17 | -not -path "*/node_modules/*" -not -path "*/vendor/*" \ |
| 18 | | xargs wc -l 2>/dev/null \ |
| 19 | | awk '$1 > 100 && $2 != "total" {print $1, $2}' \ |
| 20 | | sort -rn | head -20 |
| 21 | ``` |
| 22 | |
| 23 | ### 2. Multi-grep symbols (compact JSON) |
| 24 | |
| 25 | ```bash |
| 26 | rg --json -g '*.ts' -g '*.tsx' 'export (function|class|const) (\w+)' src/ \ |
| 27 | | jq -r 'select(.type=="match") | "\(.data.path.text):\(.data.line_number) \(.data.lines.text)"' \ |
| 28 | | head -50 |
| 29 | ``` |
| 30 | |
| 31 | ### 3. Dependencies with versions |
| 32 | |
| 33 | ```bash |
| 34 | # Node |
| 35 | jq -r '.dependencies, .devDependencies | to_entries[] | "\(.key)@\(.value)"' package.json 2>/dev/null |
| 36 | |
| 37 | # PHP |
| 38 | jq -r '.require, ."require-dev" | to_entries[] | "\(.key)@\(.value)"' composer.json 2>/dev/null |
| 39 | ``` |
| 40 | |
| 41 | ### 4. Error log scan |
| 42 | |
| 43 | ```bash |
| 44 | grep -rEn 'ERROR|FATAL|Exception|panic:|stack trace' \ |
| 45 | --include="*.log" logs/ 2>/dev/null \ |
| 46 | | tail -30 |
| 47 | ``` |
| 48 | |
| 49 | ### 5. Lines of code by extension |
| 50 | |
| 51 | ```bash |
| 52 | find . -type f \( -name "*.ts" -o -name "*.tsx" -o -name "*.js" -o -name "*.py" -o -name "*.php" \) \ |
| 53 | -not -path "*/node_modules/*" -not -path "*/vendor/*" -not -path "*/.git/*" \ |
| 54 | -exec wc -l {} + \ |
| 55 | | awk '{ext=$2; sub(/.*\./,"",ext); sum[ext]+=$1} END {for (e in sum) print sum[e], e}' \ |
| 56 | | sort -rn |
| 57 | ``` |
| 58 | |
| 59 | ## Anti-Pattern |
| 60 | |
| 61 | **Do NOT** Read 10 files sequentially to count their lines, list their exports, or check their size. That is ~6KB context per file = ~60KB wasted for a result that fits in 1KB. |
| 62 | |
| 63 | ``` |
| 64 | WRONG: Read(f1.ts) → Read(f2.ts) → ... → Read(f10.ts) → manual tally |
| 65 | RIGHT: Bash(find ... | xargs wc -l | awk ...) → 1 compact table |
| 66 | ``` |
| 67 | |
| 68 | ## Before / After |
| 69 | |
| 70 | **Task:** "Find files > 100 lines in `src/`." |
| 71 | |
| 72 | - Before: 10 × Read full file → ~60KB tokens consumed, then mental wc. |
| 73 | - After: 1 × `find src -name '*.ts' | xargs wc -l | awk '$1>100'` → ~1KB result. |
| 74 | |
| 75 | **~60× reduction. Use the script.** |