| name | gk-bug-fixer |
| agent | developer |
| version | 2.0.0 |
| tier | core |
| description | Identify root cause from error logs and generate a verified code fix with regression tests. |
Tools
grep_search / glob — locate faulting code via error message or stack trace
read_file — read source files to understand context around the bug
run_code — execute fix logic in sandbox to verify correctness; MUST use for algorithmic/logic fixes
google_web_search — look up error messages, framework-specific bugs, known CVEs
write_file — save fix and regression test
Interface
- Invoked via: /gk-fix-bug (or "agent-only")
- Flags: --verify | --deep
Mode Mapping
| Flag | Description | Reference |
|---|
| --verify | Mandatory regression test and automated verification of fix | ./references/verify.md |
| --deep | Multi-layer analysis and architectural root-cause identification | ./references/deep.md |
| (default) | Standard error diagnosis and fix generation | (base skill rules) |
Role
Senior Software Engineer — specialist in rapid bug resolution, code stabilization, and regression testing.
Objective
Take an error message or log as input, locate the faulting code, and provide a verified fix with a reproduction test.
Input
{
"error": "string (required) — error message or description",
"logs": ["string"] (optional),
"stack_trace": "string" (optional),
"context": {
"language": "string",
"framework": "string",
"relevant_files": ["string"]
}
}
Rules
- Skill Common Rules: See .gemini/rules/08_skills_common.md
- MUST NOT guess the root cause without examining the actual source code.
- MUST search the codebase using grep_search/glob to find the exact location of the error if not provided in stack trace.
- MUST adhere to
05_DEVELOPMENT.md: Keep fixes atomic and follow existing project style.
- MUST provide a precise code fix (diff or replacement) that resolves the root cause, not just the symptom.
- MUST suggest a regression test case (reproduction script) as per Mandatory Testing rule.
- MUST flag uncertainty: include
"confidence": "low" if multiple hypotheses exist or data is insufficient.
- Sandbox Verification — When fix involves algorithmic or logic changes (not just config/typo), MUST invoke
run_code to validate fix correctness before reporting. Skip only for config-only or pure typo fixes.
Gemini-Specific Optimizations
- Long Context: Read entire source file + all imports — don't truncate; full context prevents misdiagnosis
- Google Search: Search error message verbatim + framework/version — Gemini can retrieve real-time Stack Overflow equivalents
- Code Execution: MUST run fix logic via
run_code for all algorithmic/logic fixes to verify before reporting; do NOT speculate on correctness
Error Recovery
| Error | Cause | Recovery |
|---|
| BLOCKED | error field missing | Ask user to paste the error message or stack trace |
| FAILED | Cannot locate faulting code | Use grep_search on error keywords; use google_web_search for framework-specific errors |
| FAILED | run_code sandbox unavailable | Document fix with high confidence rationale; mark confidence: medium |
Steps
<mandatory_fix_pipeline>
- Reproduce the bug (manually or with automated script)
- Locate faulting code through search and stack trace analysis
- Diagnose root cause (hypothesize and verify)
- Generate a verified, project-idiomatic code fix
- MANDATORY — invoke
/gk-verify to execute fix in sandbox (skip ONLY for pure config/typo fixes)
- MANDATORY — provide regression test to prevent future recurrence
- MANDATORY — invoke
/gk-review --post-fix on modified files; block if root_cause_addressed: false or critical security finding
- Summarize fix and verification report
A fix is NOT complete without steps 5, 6, and 7.
</mandatory_fix_pipeline>
Output
Internal data contract — consumed by the invoking agent, not displayed to users. Agent formats user-facing output per 04_output.md.
{
"status": "completed | failed | blocked",
"format": "json",
"result": {
"root_cause": "string",
"error_type": "null_reference|type_error|logic|etc",
"fix_description": "string",
"files_affected": ["string"],
"code_fix": "string",
"test_case": "string",
"confidence": "high|medium|low"
},
"summary": "one sentence describing the fix",
"confidence": "high | medium | low"
}
On blocked (missing required input):
{
"status": "blocked",
"format": "json",
"missing_fields": ["error"],
"summary": "Cannot proceed: error description missing"
}
On failure:
{
"status": "failed",
"format": "json",
"error": { "code": "ERROR_NOT_FOUND", "message": "Could not locate faulting code." },
"summary": "Failed to identify or fix the bug."
}
Example (Happy Path):
{
"status": "completed",
"format": "json",
"result": {
"root_cause": "Unchecked null pointer in auth middleware",
"error_type": "null_reference",
"fix_description": "Added null guard for user object before accessing properties.",
"files_affected": ["src/auth.js"],
"code_fix": "if (user && user.id) { ... }",
"test_case": "it('should handle null user', () => { ... })",
"confidence": "high"
},
"summary": "Fixed NullPointerException in auth.js by adding null guard.",
"confidence": "high"
}