agentleFS
camilo-acevedocamilo-acevedo/claude-skills/log-extract/SKILL.md

log-extract

Skill0 starsChanged 7 months agoMITView on GitHub

Extract relevant lines from a large log file: error / warning / panic / traceback patterns plus N lines of surrounding context, with deduplicated stack traces. Returns a compact summary instead of streaming the whole log into Claude's context. Use for production logs, Sentry exports, test output captured to disk, debug traces, etc.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Do NOT invoke when:

    line 27
  2. Very specific:

    Run these in a single parallel Bash batch against the log path <LOG>:

    line 46
  3. Very specific:

    If nodedup=true, skip step 4-5 above and treat every hit as its own group.

    line 78
  4. Very specific:

    If a group has only one occurrence, use [×1 at <time>] (or just [×1] if no timestamp could be parsed).

    line 114

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 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

log-extract

A Markdown-only skill — no Python, no scripts. You (Claude) extract the relevant lines from a log file using grep -nC, head, tail, and wc via the Bash tool, then deduplicate and render.

When to invoke

Invoke log-extract when ANY of these apply:

  • The user points you at a log file and asks "what's wrong?" or "find the error".
  • You're about to cat / Read a log file larger than ~500 lines.
  • You need to find specific events in a log without paying for the whole file.

Do NOT invoke when:

  • The log is small (<200 lines) — just read it.
  • The user wants a specific exact section (use Read with line offsets).
  • The file is structured data (JSON / CSV) — use the right parser instead.

Defaults

SettingDefaultOverride with
Context lines around each match2context=N
Max hit groups shown30max=N
Head lines0head=N
Tail lines5tail=N
Deduplicateonnodedup=true
Pattern (extended regex, case-insensitive)(error|errno|exception|traceback|failed|failure|panic|fatal|warn(ing)?)pattern="<regex>"

How to run

Run these in a single parallel Bash batch against the log path <LOG>:

CommandYields
wc -l "<LOG>"Total line count.
head -n <head_n> "<LOG>"Head lines (skip if head_n is 0).
tail -n <tail_n> "<LOG>"Tail lines.
grep -niE -C <context> "<pattern>" "<LOG>" | head -n <(max+10)*(2*context+1)>Candidate hits with context.

The grep -C output uses -- as a group separator and lines like 123:<line text> for matched lines, 124-<line text> for context. Parse the output into groups split on --.

Deduplication

For each hit group, build a normalized signature by collapsing the matched lines only (ignore context lines for the signature):

  1. Strip leading timestamps. Common formats to drop:
    • YYYY-MM-DD HH:MM:SS(.fff)?
    • [YYYY/MM/DD HH:MM:SS]
    • ISO 8601 with timezone
    • Bare HH:MM:SS
  2. Strip ANSI escapes: s/\x1B\[[0-9;]*[a-zA-Z]//g
  3. Replace numbers with N (matches PIDs, ports, addresses, line numbers).
  4. Lowercase.

Group hits whose normalized signature is identical. Record:

  • count (number of occurrences),
  • first_time and last_time (parsed timestamps if any),
  • one representative hit group (the first occurrence, with its full context).

If nodedup=true, skip step 4-5 above and treat every hit as its own group.

Cap the visible groups at max (default 30). Sum the rest into a … (+N more hit groups) line.

Output format

log-extract: <path> (<total_lines> lines, <hits> hits → <unique_groups> unique)

head (<N>):
  <line>
  …

hits:

[×<count> — first at <first_time>, last at <last_time>]
  <context line>
  <matched line>
  <context line>

[×<count> at <single_time>]
  <context>
  <matched>
  <context>

… (+<extra> more hit groups)

tail (<N>):
  <line>
  …
  • Omit head if head_n=0 or no lines.
  • Omit hits: body entirely if there are no matches; instead print a single line no matches for pattern "<pattern>".
  • If a group has only one occurrence, use [×1 at <time>] (or just [×1] if no timestamp could be parsed).

Notes

  • The default pattern is broad on purpose. Pass a tighter pattern= when the user knows what they're looking for (e.g. pattern="TimeoutError").
  • For very large logs (multi-GB), grep streams the file — no memory concerns. The Bash tool may truncate stdout, so use the \| head -n <K> cap shown above to keep output bounded.
  • For non-UTF-8 logs, add LC_ALL=C before grep to avoid locale-related slowdowns and decoding errors.
  • This skill never modifies the log file.

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.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

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.