Introduction¶
When troubleshooting online incidents, the common process is: take a piece of access.log, app.log, or syslog text, guess the format first, then use grep and manual statistics to find the peak times for errors. Log lines often carry changing IPs, durations, and UUIDs, and the same class of errors is split into many lines, making it difficult to directly enter them into a ticket. The clean-log-toolkit introduced below targets this kind of semi-structured, timestamped local log: parsing, aggregation, filtering, and report output are completed locally using Python 3 standard libraries, without pulling third-party dependencies or initiating remote calls.
What is This¶
clean-log-toolkit is a type of Agent Skill on SkillHub (ID: @user_15292d5a/yjkj-clean-log-toolkit), classified as it-ops-security, source community, publisher user_15292d5a, current SkillHub version 1.0.1, tag requires_api_key=false (no API Key required). The SkillHub page has a rating of 100,000 and a total download count of 714 (as of the time of data collection).
The Skill itself is a set of Python scripts placed in the Skill directory (parse.py, errors.py, grep.py, etc.), for Agents to invoke according to documentation when users ask for needs such as “parse this log”, “count errors”, or “filter by time window”. Compared to simply verbalizing grep/awk steps, it encapsulates format sniffing, timestamp parsing, level normalization, and error fingerprint clustering into a fixed toolchain, outputting TSV/CSV/JSONL as well as JSON/Markdown/CSV reports, making it easy to paste into tickets or subsequent pipelines.
Core Capabilities¶
The following capabilities all come from the SkillHub introduction and the SKILL.md within the Skill package.
Log Parsing (scripts/parse.py)¶
- Sniffs the first ~50 lines of the file to automatically identify
apache-common,apache-combined,nginx-access,syslog,json-line; if none match, it falls back to generic “timestamp + level + message” extraction. - Supports explicit format specification with
--format;json-linesupports selecting fields with--fields. - Supports named groups in
--regex, allowing custom line formats to be written in a structured way. - Outputs CSV, TSV, or JSONL.
Error Aggregation and Reporting (scripts/errors.py)¶
- Statistics by level (default focuses on
WARN/ERROR/FATAL, can be limited with--level). - Timeline is bucketed by
minute/hour/day(--bucket). - Performs fingerprint normalization on messages (replacing numbers, UUIDs, hex strings,
file:line, embedded timestamps, etc., with placeholders) and uses--topto display the highest frequency error groups. - Outputs a terminal summary or writes to JSON / Markdown / CSV (
--output).
Log-Aware Retrieval (scripts/grep.py)¶
- Combines
--pattern,--not-pattern,--level,--since,--until, as well as-B/-A/-Ccontext lines. - Supports common filtering options like
--invert,--with-line, etc. --since/--untilsupport multiple types of timestamp formats consistent with the parsing script (ISO 8601, common Apache formats, syslog, etc.).
Real-time Tracking (scripts/follow.py)¶
Documented as a v0.2.0 addition in the Skill package documentation: follows file growth while maintaining similar filtering semantics to grep.py, handles log rotation, and provides options like --max-events, --timeout, and --json for convenient use in CI or limited-duration runs.
Dependencies and Environment¶
- Pure Python 3 standard library, no pip dependencies, no remote API.
scripts/check_deps.shis used to confirm thatpython3exists on the local machine.- Paths are validated by
safe_path(); read/write is limited to input/output paths specified by the caller. Exit codes are standardized across scripts as0/1/2to facilitate piping.
Installation and Activation¶
1. Install SkillHub CLI (if not yet installed)¶
For full installation instructions, see the SkillHub installation documentation (https://skillhub.cn/install/skillhub.md). You can first check:
command -v skillhub && skillhub --version
If not installed, you can execute the curl installation script mentioned in the documentation (full installation or --cli-only for CLI only).
2. Install clean-log-toolkit¶
The SkillHub page requires installing the ID @user_15292d5a/yjkj-clean-log-toolkit. The equivalent command in the search index is:
skillhub install yjkj-clean-log-toolkit --namespace user_15292d5a --dir <current Agent's skills directory>
When installing, you must use --dir to point to the current environment’s skills directory; otherwise, it defaults to ./skills/ which may not be loaded by the Agent. Common path examples (excerpted from installation documentation):
- Cursor:
~/.cursor/skills/ - Claude Code:
~/.claude/skills/ - Codex:
~/.codex/skills/or.agents/skills/in the project
After installation, the scripts are located under scripts/ in the Skill subdirectory; the commands in the next section need to be executed in the corresponding Skill root directory, or the path needs to be changed to an absolute path.
3. Enable in Agent¶
After configuring the Skill directory to the Agent’s skills search path, restart or refresh the skill list (steps vary by product, refer to official documentation). Trigger scenarios include: local log inspection, error summary, filtering by time and level, generating copyable Markdown reports, etc., consistent with the capability descriptions in the Skill introduction.
Typical Usage¶
The following examples are excerpted from the Quick start in the Skill package SKILL.md; assuming the current working directory is the root directory of the installed yjkj-clean-log-toolkit Skill.
Parse unknown format logs and export to CSV:
python3 scripts/parse.py app.log app.csv
Specify Apache Combined Log or syslog:
python3 scripts/parse.py access.log out.jsonl --format apache-combined
python3 scripts/parse.py syslog.txt out.csv --format syslog
Custom named grouping regex:
python3 scripts/parse.py app.log structured.csv \
--regex '^(?P<ts>\S+)\s+(?P<level>\S+)\s+(?P<message>.*)$'
Error aggregation and ticket-ready Markdown:
python3 scripts/errors.py app.log
python3 scripts/errors.py app.log --bucket minute --top 20
python3 scripts/errors.py app.log --level ERROR,FATAL
python3 scripts/errors.py app.log --output report.md
Retrieve by level and time window:
python3 scripts/grep.py app.log --pattern "Database" --level ERROR,FATAL
python3 scripts/grep.py app.log \
--since "2026-05-10T10:00:00Z" \
--until "2026-05-10T11:00:00Z"
python3 scripts/grep.py app.log --pattern "FATAL" -C 1 --with-line
Piping (parse successfully, then generate report):
python3 scripts/parse.py raw.log structured.jsonl \
&& python3 scripts/errors.py raw.log --output ticket.md \
&& cat ticket.md
Suitable Scenarios and Notes¶
Who is this for¶
- R&D and operations personnel who need to process logs in offline or intranet environments and do not wish to temporarily install an analysis stack.
- Teams that want Agents to complete “parse → aggregate → report” using fixed scripts rather than rewriting a shell script every time.
- When
clean-csv-toolkit/clean-text-toolkitalready exist, the output ofparse.pycan be fed into further table or desensitization processes (paired instructions in the Skill documentation).
Limitations and Gotchas¶
- The regex parsing is pragmatic; lightly malformed Apache/nginx/syslog lines may be accepted; strict RFC validation is not within scope.
- The fingerprints in
errors.pyare heuristic aggregation; lines that differ only in numbers/hashes but have the same semantics may be merged; if fine-grained analysis is needed, increase--topand check samples. - Logs may contain sensitive information; review paths and content before outputting reports; consider using a desensitization Skill if necessary.
- The version number in the Skill package documentation may differ from the version number on the SkillHub page (page is 1.0.1, header of SKILL.md in package is v0.2.0); refer to the
SKILL.mdin the local package and the--helpof each script.
Conclusion¶
clean-log-toolkit puts the most common steps of local log processing—identifying format, structuring, counting errors, and retrieving lines by conditions—into a single set of dependency-free Python scripts, suitable for Agents to repeatedly invoke during troubleshooting conversations. Official SkillHub page: https://www.skillhub.cn/skills/user_15292d5a/yjkj-clean-log-toolkit ; API ID entry: https://api.skillhub.cn/user_15292d5a/yjkj-clean-log-toolkit .