go-codemod

Solid

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

AI & Automation 4,550 stars 412 forks Updated today MIT

Install

View on GitHub

Quality Score: 91/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Go Codemod Implementation Guide Use this skill when adding or updating codemods used by `gh aw fix`. ## Understand the fix pipeline first 1. 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 2. Review the codemod registry in `pkg/cli/fix_codemods.go`. 3. Review helper utilities in `pkg/cli/yaml_frontmatter_utils.go` and reusable codemod helper constructors in `pkg/cli/codemod_factory.go`. ## Implementation steps 1. Create a new codemod file in `pkg/cli/` named `codemod_<feature>.go`. 2. Add a package logger with `logger.New("cli:codemod_<feature>")`. 3. Implement `get<Feature>Codemod() Codemod` and populate all metadata fields: - `ID` (stable, unique) - `Name` (human-readable) - `Description` (clear migration behavior) - `IntroducedIn` (release version) 4. 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 5. Prefer existing helpers before writing custom parsing logic: - `findAndReplaceInLine` - `removeFieldFromB...

Details

Author
github
Repository
github/gh-aw
Created
9 months ago
Last Updated
today
Language
Go
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category