Boost Repo Health With Weekly Maintenance Reports

by Admin 50 views
Boost Repo Health with Weekly Maintenance Reports

Hey guys! Keeping a repository healthy can feel like herding cats, right? Technical debt sneaks in, TODO comments pile up, and suddenly you're staring at a codebase that's seen better days. That's why I'm stoked to share a cool solution: a weekly maintenance workflow! This workflow is designed to automate those pesky, easily-forgotten tasks that keep your repo in tip-top shape. We'll be using GitHub Actions and a bit of magic to generate comprehensive reports, so you're always in the know.

The Problem: Repository Rot

Let's be real, repository maintenance often takes a backseat to feature development. But ignoring it can lead to some serious headaches. Hereโ€™s a rundown of common issues that can plague a project, and the pain they bring:

  • Accumulating TODO comments: These are like little landmines, waiting to trip you up later. They indicate unfinished work, potential bugs, or areas needing attention. Left unchecked, they can make your code harder to understand and maintain.
  • Outdated patterns: Code evolves, and so should your patterns. But old, inefficient, or deprecated patterns can linger, causing performance issues, security vulnerabilities, or simply making the code harder to read.
  • Version file drift: Keeping versions synchronized across your project (e.g., in plugin.json, marketplace.json, and SKILL.md) is crucial. Mismatched versions can lead to compatibility problems and confusion.
  • Stale issues: Old, unresolved issues clutter your issue tracker and can signal a lack of engagement or clarity. They can also hide important new issues.
  • Outdated documentation: Documentation is the unsung hero of any project. When it's out of sync with the code, it becomes useless and can lead to frustration and wasted time.
  • Dependency health: Keeping your dependencies up-to-date is vital for security. Outdated dependencies can have known vulnerabilities, leaving your project exposed to attack.

The Solution: Automated Weekly Audits

Our solution is a weekly scheduled workflow that runs automatically. It audits your repository and generates a summary issue, saving you time and giving you the overview you need. Let's break down the core components:

name: Weekly Maintenance Report

on:
  schedule:
    - cron: "0 9 * * 1"  # Monday 9:00 UTC
  workflow_dispatch:      # Manual trigger

jobs:
  maintenance:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      issues: write
      
    steps:
      - uses: actions/checkout@v4
      
      - uses: anthropics/claude-code-action@v1
        id: report
        with:
          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
          prompt: |
            Perform a weekly maintenance audit of this repository.
            
            ## Checks to Perform
            
            1.  **TODO Comments**
                -   Search for TODO, FIXME, HACK, XXX comments
                -   List file, line, and comment content
                -   Count total
            
            2.  **Version Consistency**
                -   Check plugin.json, marketplace.json, skill SKILL.md versions
                -   Report if any mismatch
            
            3.  **Stale Issues**
                -   Count issues with no activity >30 days
                -   List top 5 oldest open issues
            
            4.  **Open PRs**
                -   Count open PRs
                -   List any >7 days old
            
            5.  **Documentation Freshness**
                -   Check if README.md mentions current version
                -   Check if CLAUDE.md has recent updates
            
            6.  **Dependency Health** (if applicable)
                -   Check for known security advisories
                -   Note any significantly outdated deps
            
            7.  **Plugin Structure**
                -   Verify no draft files in production directories
                -   Check for orphaned files
            
            Create a comprehensive markdown report.
          claude_args: |
            --allowedTools "Read,Glob,Grep,Bash(gh issue list:*),Bash(gh pr list:*)"
            
      - name: Create Maintenance Issue
        env:
          GH_TOKEN: ${{ github.token }}
        run: |
          gh issue create \
            --title "Weekly Maintenance Report - $(date +%Y-%m-%d)" \
            --label "automation,documentation" \
            --body "${{ steps.report.outputs.result }}"
  • name: Weekly Maintenance Report: Sets a descriptive name for the workflow.
  • on: schedule: Triggers the workflow on a schedule. Here, it runs every Monday at 9:00 UTC (using the cron expression "0 9 * * 1").
  • on: workflow_dispatch: Allows you to manually trigger the workflow from the GitHub UI.
  • jobs: maintenance: Defines the job that performs the maintenance tasks.
  • runs-on: ubuntu-latest: Specifies the operating system for the job.
  • permissions: Sets permissions for the job, allowing it to read contents and write issues.
  • steps: Contains the individual steps of the job.
  • uses: actions/checkout@v4: Checks out the repository code.
  • uses: anthropics/claude-code-action@v1: This is where the magic happens. It leverages the Claude Code action to analyze the repository based on the prompt we provide.
    • anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}: You'll need an Anthropic API key to use this. Store it as a secret in your repository settings.
    • prompt: This is the heart of the workflow. It's a set of instructions given to the Claude Code action, telling it what to look for and how to format the report. The prompt includes detailed checks for TODO comments, version consistency, stale issues, open PRs, documentation freshness, dependency health, and plugin structure. It's fully customizable.
    • claude_args: Specifies arguments for the Claude Code action, allowing for specific tools and capabilities. In this case, it allows reading files, searching files, and using the GitHub CLI for listing issues and pull requests.
  • name: Create Maintenance Issue: Creates a new issue in your repository with the generated report. It uses the GitHub CLI to create the issue, sets the title, labels, and the body of the issue with the report generated by the Claude Code action.

Report Format: A Clear Snapshot

The workflow generates a nicely formatted markdown report, giving you a clear overview of your repository's health. It provides a concise summary, action items, and areas where no action is needed. This allows you to quickly understand what needs your attention.

# Weekly Maintenance Report - 2025-01-15

## ๐Ÿ“‹ Summary

| Check                | Status | Count |
| -------------------- | ------ | ----- |
| TODO Comments        | โš ๏ธ     | 3 found |
| Version Consistency  | โœ…     | All match (0.3.0) |
| Stale Issues         | โš ๏ธ     | 2 issues >30 days |
| Open PRs             | โœ…     | 1 open (<7 days) |
| Documentation        | โœ…     | Up to date |
| Dependencies         | โœ…     | No advisories |
| Plugin Structure     | โœ…     | Clean |

## ๐Ÿ”ง Action Items

### TODO Comments (3)

| File                  | Line | Comment                  |
| --------------------- | ---- | ------------------------ |
| `commands/init.md`   | 45   | `TODO: Add retry logic` |
| `skills/vision-discovery/SKILL.md` | 123  | `FIXME: Update example` |
| `CLAUDE.md`          | 500  | `TODO: Document new pattern` |

### Stale Issues

-   #42 - "Feature request: export to CSV" (45 days)
-   #38 - "Question about prioritization" (32 days)

## โœ… No Action Needed

-   Version files are consistent
-   No draft files in production directories
-   README references current version
-   All PRs are recent

---
*Generated automatically by Weekly Maintenance workflow*

The report includes:

  • A summary table providing a quick overview of the repository's health.
  • Detailed action items highlighting specific issues found, such as TODO comments and stale issues.
  • A section noting areas where no action is needed, reassuring you that things are in good shape.

Benefits: Why Automate?

Automating repository maintenance offers several key benefits. It ensures proactive care and improves team efficiency.

Benefit Impact
Proactive maintenance Catches issues before they become major problems.
Visibility Increases team awareness of tech debt.
Accountability Ensures a regular review cadence.
Automation Eliminates manual effort for report generation.

Configuration Options: Tailor It to Your Needs

The workflow is designed to be flexible. Here are some configuration options to tailor the workflow to your specific needs:

Adjustable Thresholds

You can easily adjust the thresholds for stale issues and old pull requests to match your team's processes. For example:

env:
  STALE_ISSUE_DAYS: 30
  OLD_PR_DAYS: 7
  TODO_ALERT_THRESHOLD: 5  # Warn if more than this many

Notification Options

  • Issue only (default): Creates a GitHub issue for the report.
  • Slack integration: Post the summary to a Slack channel. (Implementation not provided in the original code, but you could add a step to send a Slack message using a Slack app.)
  • Email digest: Send the report to a list of maintainers. (Similar to Slack, this would require adding a step to send an email using a service like SendGrid or AWS SES.)

Implementation: Getting Started

Ready to put this workflow into action? Hereโ€™s a simple checklist to get you started:

  • Create .github/workflows/weekly-maintenance.yml: Copy the provided YAML code into a new file in your repository under the .github/workflows directory.
  • Test with manual trigger (workflow_dispatch): Trigger the workflow manually from the