go-codemod

Implement and test Go codemods for the gh aw fix command.

5.1k|530|Updated Aug 12, 2025
One-click install
npx skills add https://github.com/github/gh-aw --skill go-codemod
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-codemod
Source: https://github.com/github/gh-aw/tree/main/.github/skills/go-codemod
Command: npx skills add https://github.com/github/gh-aw --skill go-codemod

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Adding or updating codemods for the gh aw fix command requires understanding the fix pipeline, registry ordering, frontmatter transformation helpers, and strict testing conventions, which is error-prone without a structured guide.

Core Features & Use Cases

  • Codemod Implementation Guidance: Walks through creating codemod files in pkg/cli/, defining metadata fields (ID, Name, Description, IntroducedIn), and using existing frontmatter transformation helpers.
  • Registry and Ordering Rules: Explains how to register codemods in GetAllCodemods() and update registry/order tests since codemods run sequentially.
  • Testing Standards: Defines required test coverage including happy path, no-op, idempotence, comment/formatting preservation, dependency injection, and fuzz tests for complex codemods.
  • Use Case: When deprecating a frontmatter field in agentic workflows, use this Skill to implement a migration codemod that rewrites the field safely, preserves markdown bodies, and passes all registry and unit tests.

Quick Start

Use the go-codemod skill to implement a new codemod that migrates a deprecated frontmatter field for the gh aw fix command.

Frequently Asked Questions about go-codemod

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new codemod to the gh aw fix command?

Create a codemod_<feature>.go file in pkg/cli/, implement get<Feature>Codemod() with full metadata, transform only frontmatter using helpers like applyFrontmatterLineTransform, then register it in GetAllCodemods() in fix_codemods.go.

How do I test a Go codemod for frontmatter migration?

Create codemod_<feature>_test.go covering metadata correctness, happy path migration, no-op behavior, idempotence, and preservation of comments, indentation, and markdown body. Update fix_codemods_test.go with expected IDs and order.

Why does codemod order matter in the fix pipeline?

Codemods run sequentially in registry order, and frontmatter is re-parsed before each one, so later codemods observe prior transformations. Order changes must be reflected in the registry order tests.

When should a codemod use dependency injection?

Use a ...WithDeps constructor when the codemod depends on external data or side effects, so tests can mock behavior and cover both success and fallback or error paths.

When should I add fuzz tests for a codemod?

Add fuzz tests in codemod_<feature>_fuzz_test.go when complexity is high, such as expression rewriting or parser-like behavior, following the pattern in codemod_steps_run_secrets_env_fuzz_test.go.