mcpbeat Sign in

Go Codemod Agent Skill

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

877 tokens
context cost
the whole folder, loaded on every use
1
files
instructions only
0
copies elsewhere
how many repositories repackaged it
4864
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/github/gh-aw --skill go-codemod

The instruction itself

7 sections, as written by the author

Go Codemod Implementation Guide

Use this skill when adding or updating codemods used by gh aw fix.

Understand the fix pipeline first

  • Review pkg/cli/fix_command.go to understand execution flow:
  • codemods are loaded once via GetAllCodemods()
  • each codemod is applied in registry order
  • frontmatter is re-parsed before each codemod
  • codemods must return (newContent, applied, error) and be safe for no-op input
  • Review the codemod registry in pkg/cli/fix_codemods.go.
  • Review helper utilities in pkg/cli/yaml_frontmatter_utils.go and reusable codemod helper constructors in pkg/cli/codemod_factory.go.

Implementation steps

  • Create a new codemod file in pkg/cli/ named codemod_<feature>.go.
  • Add a package logger with logger.New("cli:codemod_<feature>").
  • Implement get<Feature>Codemod() Codemod and populate all metadata fields:
  • ID (stable, unique)
  • Name (human-readable)
  • Description (clear migration behavior)
  • IntroducedIn (release version)
  • In Apply:
  • check frontmatter preconditions first
  • return unchanged content and applied=false when migration is not needed
  • transform only frontmatter using applyFrontmatterLineTransform from pkg/cli/yaml_frontmatter_utils.go
  • preserve comments/formatting/markdown body
  • avoid lossy rewrites and avoid touching unrelated keys
  • Prefer existing helpers before writing custom parsing logic:
  • findAndReplaceInLine
  • removeFieldFromBlock
  • removeParentBlockIfTrulyEmpty
  • newFieldRemovalCodemod
  • newMoveTopLevelKeyToOnBlockCodemod
  • If the codemod depends on external data or side effects, inject dependencies through a ...WithDeps constructor so tests can mock behavior.
  • Register the codemod in pkg/cli/fix_codemods.go within GetAllCodemods().

Testing requirements

Create pkg/cli/codemod_<feature>_test.go and cover:

  • Metadata correctness (ID, Name, Description, IntroducedIn, Apply != nil).
  • Happy path migration with expected output.
  • No-op behavior when deprecated input is absent.
  • Idempotence behavior (already-migrated input remains unchanged).
  • Preservation guarantees:
  • inline comments
  • indentation
  • markdown body after frontmatter
  • Edge cases specific to the codemod (nested fields, mixed forms, ordering constraints, strict-mode checks, etc.).
  • Dependency-injection behavior if ...WithDeps exists (success and fallback/error paths).

When complexity is high (expression rewriting, parser-like behavior), add fuzz tests in codemod_<feature>_fuzz_test.go using the pattern in pkg/cli/codemod_steps_run_secrets_env_fuzz_test.go.

Registry/order tests

After adding a codemod, update pkg/cli/fix_codemods_test.go:

  • Expected codemod IDs list.
  • Expected codemod order list.

Order matters because codemods run sequentially and later codemods observe prior transformations.

Validation commands

Run targeted checks first:

  • go test -v ./pkg/cli -run Codemod -count=1
  • go test -v ./pkg/cli -run Fix -count=1

Then run repository standards:

  • make build
  • make test-unit
  • make lint

Quality bar

A codemod is ready only when it is:

  • deterministic
  • safe on repeated runs
  • conservative (no unrelated rewrites)
  • fully covered by tests for migration and no-op paths
  • registered and order-verified in fix codemod registry tests

Other skills for the same job

different authors, same section of the catalogue
Webapp Testing
by anthropics
vendor ×12

Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.

6k tokens scripts
Finishing A Development Branch
by ZhanlinCui
×7

Use when implementation is complete, all tests pass, and you need to decide how to integrate the work - guides completion of development work by presenting structured options for merge, PR, or cleanup

1k tokens
Test Driven Development
by w95
×7

Use when implementing any feature or bugfix, before writing implementation code

2k tokens
Systematic Debugging
by ratacat
×7

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes

10k tokens scripts
Verification Before Completion
by ZhanlinCui
×6

Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always

1k tokens
Backtest Expert
by BaggaT236
×3

Expert guidance for systematic backtesting of trading strategies. Use when developing, testing, stress-testing, or validating quantitative trading strategies. Covers "beating ideas to death" methodology, parameter robustness testing, slippage modeling, bias prevention, and interpreting backtest results. Applicable when user asks about backtesting, strategy validation, robustness testing, avoiding overfitting, or systematic trading development.

15k tokens scripts
Adaptyv
by christophacham
×3

Cloud laboratory platform for automated protein testing and validation. Use when designing proteins and needing experimental validation including binding assays, expression testing, thermostability measurements, enzyme activity assays, or protein sequence optimization. Also use for submitting experiments via API, tracking experiment status, downloading results, optimizing protein sequences for better expression using computational tools (NetSolP, SoluProt, SolubleMPNN, ESM), or managing protein design workflows with wet-lab validation.

16k tokens
Aeon
by christophacham
×3

This skill should be used for time series machine learning tasks including classification, regression, clustering, forecasting, anomaly detection, segmentation, and similarity search. Use when working with temporal data, sequential patterns, or time-indexed observations requiring specialized algorithms beyond standard ML approaches. Particularly suited for univariate and multivariate time series analysis with scikit-learn compatible APIs.

19k tokens

How to use it

Copy the folder

Take github/go-codemod from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.