Skip to content

[plan] Create "refactoring-cadence" agentic workflow #25321

@github-actions

Description

@github-actions

Context

From the Scout analysis of issue #25311, this workflow addresses Problem 2: Lack of Continuous Refactoring.

"If you're using AI to generate code at industrial scale, you have to refactor constantly and continuously. If you don't, things immediately get out of hand."

AI's ability to generate code at high velocity accelerates technical debt accumulation. Without a forcing function, refactoring gets deferred indefinitely.

Objective

Create a new gh-aw agentic workflow called refactoring-cadence that tracks repository code health over time and automatically opens issues when the health score drops.

Workflow Prompt

Create an agentic GitHub Actions workflow called "refactoring-cadence" that:

1. Tracks a "code health score" for the repository over time using metrics like:
   - Average file length
   - Average cyclomatic complexity per function
   - Number of files that have grown >20% since last baseline
   - Number of TODO/FIXME/HACK comments added vs. resolved
2. Runs after every 10 commits (or configurable interval) on main, using a
   commit counter stored in a workflow artifact or GitHub variable
3. When the health score drops below a configurable threshold, automatically
   opens a GitHub Issue titled "🔧 Refactoring Required: Code Health Alert"
   that includes:
   - The specific files and functions that degraded
   - An AI-generated refactoring plan with prioritized action items
   - A checklist of concrete refactoring tasks for a human to approve and assign
4. Labels the issue with "refactoring" and "ai-generated"
5. Blocks merging new feature PRs until the open refactoring issue is closed
   (enforced via a branch protection rule check)

Use radon for Python complexity analysis, cargo-clippy for Rust.
Store baseline metrics as a JSON artifact per workflow run.

Files to Create

  • .github/workflows/refactoring-cadence.md — the workflow markdown file

Acceptance Criteria

  • Workflow runs on a configurable commit interval (default: every 10 commits on main)
  • Tracks 4 health metrics: avg file length, avg cyclomatic complexity, file growth, TODO churn
  • Computes a health score and compares to configurable threshold
  • Auto-opens a GitHub Issue with AI-generated refactoring plan when score drops
  • Issue is labeled refactoring and ai-generated
  • Metrics baseline stored as a JSON workflow artifact
  • Supports radon (Python) and cargo-clippy (Rust)
  • Compiled .lock.yml generated via make recompile
    Related to Blog analysis #25311

Generated by Plan Command for issue #25311 · ● 394.6K ·

  • expires on Apr 10, 2026, 1:57 PM UTC

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions