home / skills / duc01226 / easyplatform / fix-logs

fix-logs skill

/.claude/skills/fix-logs

This skill analyzes application logs to identify root causes and suggests targeted fixes to improve reliability and debuggability.

npx playbooks add skill duc01226/easyplatform --skill fix-logs

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
2.0 KB
---
name: fix-logs
description: "[Fix & Debug] ⚡ Analyze logs and fix issues"
argument-hint: [issue]
infer: true
---

**IMPORTANT:** Analyze the skills catalog and activate the skills that are needed for the task during the process.

## ⚠️ Anti-Hallucination Reminder

**Before modifying ANY code:** Verify assumptions with actual code evidence. Search for usages, read implementations, trace dependencies. If confidence < 90% on any change, investigate first or ask user. See `.claude/skills/shared/anti-hallucination-protocol.md` for full protocol.

## Mission
<issue>$ARGUMENTS</issue>

## Workflow
1. Check if `./logs.txt` exists:
   - If missing, set up permanent log piping in project's script config (`package.json`, `Makefile`, `pyproject.toml`, etc.):
     - **Bash/Unix**: append `2>&1 | tee logs.txt`
     - **PowerShell**: append `*>&1 | Tee-Object logs.txt`
   - Run the command to generate logs
2. Use `debugger` subagent to analyze `./logs.txt` and find root causes:
   - Use `Grep` with `head_limit: 30` to read only last 30 lines (avoid loading entire file)
   - If insufficient context, increase `head_limit` as needed
3. Use `scout` subagent to analyze the codebase and find the exact location of the issues, then report back to main agent.
4. Use `planner` subagent to create an implementation plan based on the reports, then report back to main agent.
5. Start implementing the fix based the reports and solutions.
6. Use `tester` agent to test the fix and make sure it works, then report back to main agent.
7. Use `code-reviewer` subagent to quickly review the code changes and make sure it meets requirements, then report back to main agent.
8. If there are issues or failed tests, repeat from step 3.
9. After finishing, respond back to user with a summary of the changes and explain everything briefly, guide user to get started and suggest the next steps.

## IMPORTANT Task Planning Notes

- Always plan and break many small todo tasks
- Always add a final review todo task to review the works done at the end to find any fix or enhancement needed

Overview

This skill automates log-driven debugging: it inspects runtime logs, identifies root causes, locates offending code, and implements fixes with iterative testing and review. It orchestrates specialized subagents to grep logs, scout the codebase, plan changes, apply fixes, run tests, and perform a code review. The process is conservative: verify assumptions against real code and logs before changing anything.

How this skill works

First the skill ensures a local logs.txt exists or sets up persistent log piping in the project scripts, then collects recent log lines to avoid loading huge files. A debugger subagent reads and summarizes the last lines, the scout locates relevant files and call sites, and the planner breaks the work into small actionable tasks. Implementation is applied incrementally, tested, and code-reviewed; failed tests or new errors trigger a new investigative cycle.

When to use it

  • When runtime errors appear in production or CI and you need a targeted fix guided by logs.
  • When a bug is reproducible but the failing code path is unclear from source alone.
  • When logs are large and you want a focused, efficient tail-and-investigate workflow.
  • When you require an auditable, stepwise debugging and fix process with testing and review.

Best practices

  • Always verify assumptions by searching for real usages and reading implementations before changing code.
  • Start with the last 20–30 log lines; increase context only when necessary to avoid noise.
  • Break fixes into small tasks and include a final review task to validate behavior and edge cases.
  • Set up permanent log piping in project scripts so future failures are reproducible locally.
  • Run unit and integration tests after each change and revert quickly if a hypothesis is disproven.

Example use cases

  • CI build fails with an exception stack trace; analyze last log lines, find the failing module, and patch null handling.
  • A web endpoint returns 500 intermittently; collect request logs, trace the controller and data layer, then add retries or validation.
  • Background worker crashes with out-of-range errors; locate the offending loop and add safe guards and tests.
  • Large app produces noisy logs; set up tee-based piping to persist logs for offline analysis and debugging.

FAQ

What if logs.txt is missing or truncated?

The skill will modify the project's run scripts to append tee-style piping and then reproduce the failure to capture fresh logs.

How does the skill avoid changing code blindly?

It follows an anti-hallucination principle: every proposed change is backed by log evidence and code references, and confidence must be high before modifying code.

Can I control how much log context is read?

Yes. The default reads the last ~30 lines; the head_limit can be increased when more context is necessary.