بنقرة واحدة
safe-code-change
// After a code change, find affected tests, update them to match new behavior, then guide the user to run validation. Use when the user has made or asked for a code change and wants to make sure nothing is broken.
// After a code change, find affected tests, update them to match new behavior, then guide the user to run validation. Use when the user has made or asked for a code change and wants to make sure nothing is broken.
Find functions with high cyclomatic complexity, excessive length, or too many parameters. Use when the user asks to find complex code, complexity hotspots, refactoring candidates, or wants to improve code maintainability.
Find unused functions, types, constants, imports, and unreachable code paths. Use when the user asks to find dead code, unused code, cleanup candidates, or wants to reduce codebase size.
Find code duplication in the codebase. Supports two modes - scoped to current branch changes or a full codebase sweep. Use when the user asks to find duplicated code, copy-paste, repeated patterns, or wants to deduplicate before a PR.
Reviews Go code for idiomatic patterns, error handling, concurrency safety, and common mistakes. Use when reviewing .go files, checking error handling, goroutine usage, or interface design.
Reviews Go test code for proper table-driven tests, assertions, and coverage patterns. Use when reviewing *_test.go files.
Investigate CI/Prow job failures on a GitHub pull request. Use when the user pastes a PR URL and asks about CI failures, red checks, test failures, or wants to understand why a job failed.
| name | safe-code-change |
| description | After a code change, find affected tests, update them to match new behavior, then guide the user to run validation. Use when the user has made or asked for a code change and wants to make sure nothing is broken. |
| disable-model-invocation | true |
After a code change is made, find and fix affected tests before running validation.
git diff --name-only
git diff --stat
List the modified production files (ignore test files, configs, docs).
Search for imports and uses of changed functions/types across all test files:
# Find test files that import the changed package
rg "github.com/openshift/lightspeed-agentic-operator/<changed_package>" --type go -g '*_test.go'
# Find direct function/type references
rg "<ChangedFunctionOrType>" --type go -g '*_test.go'
For controller or CLI changes, also check:
examples/ YAMLs only if behavior affects documented shapes (usually not test code)For each affected test file, check whether the change breaks existing tests:
Apply minimal fixes to each affected test:
Expect() assertions to match new return valuesEventually() timeouts if reconciliation logic changedExpect(err).To(MatchError(ContainSubstring(oldName))) → newNameOwnerReferencesBefore telling the user tests are ready, verify Go syntax:
go fmt <modified_test_file>
If formatting changes the file significantly, there may be syntax errors.
List all test files updated and what was changed in each:
Then guide the user to run validation:
Tests are updated. Run validation with:
go test ./... -count=1 # All unit tests (see repo CLAUDE.md for focused paths)
go vet ./... # Static checks
go fmt ./... # Formatting
If tests fail, review the specific failures and adjust expectations.
Do not run the full test suite automatically unless the user asked — they may prefer to run it themselves.