agentleFS
axiomanticaxiomantic/spellbook/skills/smart-reading/SKILL.md

smart-reading

Skill11 starsChanged 3 months agoMITView on GitHub

Full protocol for reading files or command output of unknown size: measure before reading, never truncate blindly, delegate large reads. Loaded by the file-reading rule module, which carries the one-line rule and points here.

We split this skill into the rules it gives an agent

16 rules. About 0 are common, 11 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈11

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Temp Files Demand Cleanup: - Every capture requires explicit cleanup plan.

    line 20
  2. Distinctive:

    Check size first, then act:

    line 32
  3. Distinctive:

    Always clean up temp files.

    line 79
  4. Very specific:

    Immediate cleanup: after analysis: rm /tmp/cmd-$$-output.txt

    line 81
  5. Distinctive:

    When delegating to a subagent, specify WHY you need the file.

    line 112
  6. Distinctive:

    Before reading any file or command output:

    line 179
  7. Distinctive:

    Before running command with unpredictable output:

    line 186
  8. Distinctive:

    If capturing: cleanup plan exists?

    line 188
  9. Distinctive:

    If delegating: intent specified clearly?

    line 189
  10. Distinctive:

    IF YES to first or NO to others: STOP and fix approach.

    line 198
  11. Distinctive:

    If ANY unchecked: STOP and fix approach.

    line 210
  12. Very specific:

    Do I know the size? If not, check with wc -l

    line 215
  13. Distinctive:

    Before running a command with unpredictable output:

    line 221
  14. Very specific:

    Should I capture with tee to analyze after?

    line 223
  15. Distinctive:

    If capturing: Did I plan for cleanup?

    line 224
  16. Very specific:

    If delegating: Did I specify the analysis intent clearly?

    line 225

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md
<ROLE> You are a Context Guardian. Your job: ensure no important information is silently discarded. Blind truncation (`head -100`) is your enemy. Intelligent summarization is your tool. Truncation creates false confidence - the critical error is on line 247. </ROLE><CRITICAL> **Never truncate output blindly.** Commands like `head -100`, `tail -n 50`, or arbitrary pipes that discard data are forbidden when you need to understand or analyze content. </CRITICAL>

Invariant Principles

  1. No Silent Data Loss - Blind truncation (head, tail -n, arbitrary pipes) creates false confidence. Critical errors often appear at end of output.
  2. Size Before Strategy - Unknown content size requires measurement (wc -l) before deciding read approach.
  3. Intent-Driven Delegation - Subagents read ENTIRE content, return targeted summaries. Specify WHY you need content.
  4. Temp Files Demand Cleanup - Every capture requires explicit cleanup plan. Use $$ for collision-free naming.

The Problem

Claude often pipes output through head -100 to "save tokens." This causes:

  • Silent data loss
  • Missed errors (which often appear at the END)
  • Wrong conclusions based on incomplete information
  • Wasted debugging cycles

Decision Matrix

Check size first, then act:

Line CountNeed Exact Text?Action
≤200Yes (editing)Read directly, full file
≤200No (understanding)Read directly, full file
>200Yes (editing specific section)Read directly with offset/limit to target section
>200No (understanding/analysis)Delegate to Explore subagent with intent

Before Reading Any File

wc -l < "$FILE"  # Get line count first

Command Output Capture

For commands with unpredictable output size, capture to temp file first using tee.

The Pattern

# Capture full output while still seeing it stream
# /tmp/cmd-$$-output.txt — use $$ (process ID) to avoid collisions
command 2>&1 | tee /tmp/cmd-$$-output.txt

# Check size
wc -l < /tmp/cmd-$$-output.txt

# Apply decision matrix (read directly or delegate)
# ...

# ALWAYS cleanup
rm /tmp/cmd-$$-output.txt

When to Capture vs Delegate Entirely

ScenarioApproach
Need to see output streaming AND analyze aftertee to temp file
Pure analysis, don't need streamingDelegate entire command to subagent
Interactive command or watching for specific eventRun directly, no capture

Cleanup Rules

<CRITICAL> Always clean up temp files. Use one of:
  1. Immediate cleanup after analysis: rm /tmp/cmd-$$-output.txt
  2. Trap-based cleanup for complex flows: trap 'rm -f /tmp/cmd-$$-output.txt' EXIT
  3. Delegate to subagent - subagent handles its own cleanup</CRITICAL>

Capture Examples

Test run with capture:

pytest tests/ 2>&1 | tee /tmp/test-$$-output.txt
wc -l < /tmp/test-$$-output.txt  # Check size
# If >200: delegate analysis of /tmp/test-$$-output.txt
# If ≤200: read directly
rm /tmp/test-$$-output.txt

Build with capture:

npm run build 2>&1 | tee /tmp/build-$$-output.txt
# Analyze...
rm /tmp/build-$$-output.txt

Pure delegation (no capture needed):

Task(Explore): Run `pytest tests/` and extract all failures with
stack traces. Return a summary of what failed and why.

Delegation Intents

When delegating to a subagent, specify WHY you need the file. The subagent reads ENTIRE content and returns a targeted summary.

IntentSubagent BehaviorExample Prompt
Error extractionFind all errors, warnings, failures. Return with context."Read the test output and extract all failures with their stack traces"
Technical summaryComprehensive but condensed overview preserving structure"Summarize this config file's structure and key settings"
Presence checkDoes concept X exist? Where?"Does this file implement rate limiting? If so, where and how?"
Diff-awareWhat changed and why does it matter?"Compare these two versions and explain the significant changes"
Structure overviewWhat's in this file, how is it organized"Outline the structure of this module - classes, functions, their purposes"

Delegation Template

Read [file/output] in full. [INTENT STATEMENT]

Return:
- [What you need back]
- [Any specific format requirements]

Do not truncate. Read the entire content before summarizing.

Anti-Patterns

<FORBIDDEN> - Blind truncation with `head`, `tail -n`, or pipes without size check - Reading unknown-size files without measuring first - Delegation without explicit intent statement - Leaving temp files uncleaned - Assuming errors appear at start of output </FORBIDDEN>

Forbidden:

pytest tests/ 2>&1 | head -100  # WRONG: errors often at end
cat src/large_module.py         # WRONG: might be 2000 lines

Required:

wc -l < src/large_module.py  # Returns: 1847
# Now delegate to subagent for summary, or read specific section
Task(Explore): Run pytest tests/ and analyze the output. Extract all
test failures with their full tracebacks and error messages. Summarize
the failure patterns.

When and How to Read

SituationUse Direct ReadUse Delegation
File known small (configs, small scripts)YesNo
Need exact text for editingYes (offset/limit for large)No
File already in contextYesNo
Quick verification of known linesYesNo
Test output (failures cluster unpredictably)NoYes
Build logs (errors often at end)NoYes
Large source file, need understandingNoYes
Multiple files to cross-referenceNoYes
Output where you don't know what you're looking forNoYes

Reasoning Schema

<analysis> Before reading any file or command output: 1. Size known? If not: `wc -l < "$FILE"` 2. ≤200 lines? Read directly 3. >200 AND need exact text? Read with targeted offset/limit 4. >200 AND need understanding? Delegate with explicit intent 5. About to use `head`, `tail -n`, truncating pipe? STOP. Delegate instead.

Before running command with unpredictable output: 6. Capture with tee for post-analysis? Or delegate entire command? 7. If capturing: cleanup plan exists? 8. If delegating: intent specified clearly? </analysis>

<reflection> After reading: - Did I truncate blindly? (Forbidden) - Did I check size before deciding approach? - For delegation: did I specify WHY I need content? - For temp files: cleanup planned? IF YES to first or NO to others: STOP and fix approach. </reflection>

Self-Check

Before completing:

  • Size checked before reading unknown content
  • No blind truncation used
  • Delegation includes explicit intent if used
  • Temp files cleaned up if created
  • Critical information not lost to truncation

If ANY unchecked: STOP and fix approach.

<BEFORE_RESPONDING> Before reading any file or command output:

  1. Do I know the size? If not, check with wc -l
  2. Is it ≤200 lines? → Read directly
  3. Is it >200 lines AND I need exact text? → Read with targeted offset/limit
  4. Is it >200 lines AND I need understanding? → Delegate with explicit intent
  5. Am I about to use head, tail -n, or a truncating pipe? → STOP. Delegate instead.

Before running a command with unpredictable output:

  1. Should I capture with tee to analyze after? Or delegate the entire command?
  2. If capturing: Did I plan for cleanup?
  3. If delegating: Did I specify the analysis intent clearly? </BEFORE_RESPONDING>

<FINAL_EMPHASIS> You are a Context Guardian. Your obligation: no important information is silently discarded. The critical error lives on line 247. Blind truncation destroys it before you ever see it. Check size. Delegate with intent. Clean up. Never truncate blind. </FINAL_EMPHASIS>

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.