mochammadshenna/go-adk-q/code-refactor

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Plan and execute a focused refactor. Identify the target, define the boundary, keep behaviour unchanged, and verify with tests.

Install

npx vskill@latest install mochammadshenna/go-adk-q/code-refactor

SKILL.md

Code Refactor

Use when changing the structure of existing code without changing its behaviour. A refactor that changes behaviour is a bug.

The golden rule

Refactor = behaviour unchanged, structure improved.

Before starting, write down what the code does today. After finishing, verify it still does exactly that. If you can't describe the current behaviour, you're not ready to refactor.

When to refactor in go-adk-q

Good candidates:

  • chat.go:Update() — over 700 lines; individual key handlers should be extracted to helper methods
  • renderMessages() — each role could be a method (renderUserMsg, renderAgentMsg, etc.)
  • Provider packages with copy-pasted config parsing
  • Any function over ~60 lines that mixes concerns

Bad candidates (leave alone):

  • Code you don't fully understand yet
  • Code with no tests — refactor without tests is gambling
  • Code that's about to be deleted

Process

1. Define the boundary

What exactly are you refactoring? Name the file, function, or type. Write it down.

"Extracting the "enter" key handling block in Update() (~150 lines) into handleEnterKey() (tea.Model, tea.Cmd)"

2. Confirm green baseline
bash
go test -count=1 ./... # must be green before you start

If tests are red before you start, you can't tell if your refactor broke anything.

3. Refactor in the smallest safe steps

Step types (in order of safety):

StepSafetyExample
RenameVery safeslashCmd → menuEntry
Extract functionSafeinline code → named function
Move to methodSafepackage func → method on chatModel
Restructure logicRiskyreorder conditionals
Change typesRisky[]string → []skillEntry

Do safe steps first. Run tests after each step.

4. Verify after each step
bash
go build ./...
go test -count=1 ./...

If tests go red: git diff to see exactly what changed. Revert the bad step and try again. Don't pile changes on top of a failing state.

5. Commit when green
bash
git commit -m "refactor: extract handleEnterKey from Update()"

One commit per logical refactor step.

For go-adk-q specifically

Extracting from Update()

The pattern is: pull the case body into a method, replace the body with a call.

go
// Before
case "enter":
if m.loading { break }
// ... 80 lines ...
// After
case "enter":
return m.handleEnterKey(cmds)

The method signature should be func (m chatModel) handleXxx(cmds []tea.Cmd) (tea.Model, tea.Cmd).

Renaming exported names

Use grep -rn "OldName" . to find all call sites before renaming. In this codebase, exported names from cmd/tui/ are only used within that package, but model/*/ exports are used in main.go and cmd/tui/main.go.

Moving logic to slash.go

Anything related to slash command parsing or display belongs in slash.go, not chat.go. Move it and keep chat.go as the orchestrator.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
1
7-day trend score
0

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/mochammadshenna/go-adk-q/code-refactor/badge)](https://verified-skill.com/skills/mochammadshenna/go-adk-q/code-refactor)

Something wrong with this skill or its page? Tell us.