go-codemod
БесплатноБез исполняемых скриптовНе проверенImplement and test Go codemods for the gh aw fix command.
от github★ 5 758 звёзд на GitHubОб этом скилле
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.goto 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
- codemods are loaded once via
- Review the codemod registry in
pkg/cli/fix_codemods.go. - Review
pkg/workflow/codemod/frontmatter.goand reusable constructors inpkg/cli/codemod_factory.go. Codemods and workflow linters share the authoredaw.DocumentAST.
Implementation steps
- Create a new codemod file in
pkg/cli/namedcodemod_<feature>.go. - Add a package logger with
logger.New("cli:codemod_<feature>"). - Implement
get<Feature>Codemod() Codemodand 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=falsewhen migration is not needed - transform frontmatter with
codemod.Apply(content, func(f *codemod.Frontmatter) error { ... }) - inspect authored configuration through
f.Documentorf.Lookup - use
Rename,Set,Remove, andPruneEmptyfor exact mapping paths; useEditfor arbitrary semantic transformations of the AW document - preserve comments/formatting/markdown body
- avoid indentation scanners and whole-document YAML serialization; the helper preserves key tokens for renames and shares the Actions AST source merger for structural edits
- return errors from the callback; failed transformations return the original content atomically
- Prefer existing helpers before writing custom parsing logic:
codemod.Frontmatter.Lookupcodemod.Frontmatter.Rename(existing destination fields are authoritative, including null)codemod.Frontmatter.RemoveandPruneEmpty(comment-bearing parents are retained)newFieldRemovalCodemodnewMoveTopLevelKeyToOnBlockCodemod
- If the codemod depends on external data or side effects, inject dependencies through a
...WithDepsconstructor so tests can mock behavior. - Register the codemod in
pkg/cli/fix_codemods.gowithinGetAllCodemods().
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
...WithDepsexists (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=1go test -v ./pkg/cli -run Fix -count=1
Then run repository standards:
make buildmake test-unitmake 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
Установить go-codemod в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл go-codemod?
Implement and test Go codemods for the gh aw fix command.
Как установить скилл go-codemod?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл go-codemod запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic