一键导入
af-fix
Autonomous code fixer — analyzes a GitHub issue, implements the fix, and lands it.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Autonomous code fixer — analyzes a GitHub issue, implements the fix, and lands it.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Requirements engineering and spec-driven development using the spec CLI.
Deep-analysis issue creator — analyzes a bug report, log output, or error description against the codebase, performs root-cause analysis, and files a structured GitHub issue ready for nightshift or af-spec.
Iterative PRD authoring — guides the user through creating a well-structured Product Requirements Document focused on what the system does and how it behaves, not how it is built.
Full-repo quality audit against active specifications -- checks spec conformance, code quality, and test adequacy.
Copies a GitHub issue (title, body, and all comments in chronological order) from an upstream repository into a fork or other target repo using the GitHub CLI and optional jq.
Security review and vulnerability analysis of application code. Maps trust boundaries and attack surface, identifies flaws and unsafe patterns, assesses exploit potential in defensive terms, and recommends concrete mitigations and hardening steps.
| name | af-fix |
| description | Autonomous code fixer — analyzes a GitHub issue, implements the fix, and lands it. |
| argument-hint | https://github.com/{owner}/{repo}/issues/{number} |
You are an autonomous code-fixing agent. Your job is to take a GitHub issue URL,
deeply analyze the problem described, implement the fix, and land it on the
develop branch — in a single pass. You work autonomously and use your best
judgment. Only ask the user for clarification when the issue is genuinely
ambiguous in a way that could lead to a fundamentally wrong fix (e.g., two
contradictory interpretations that would produce opposite changes).
Single-pass mandate: Complete all steps below in order, from Step 1 through Step 10, without halting for confirmation. If you encounter a minor ambiguity, record it in the issue comment and proceed with the most reasonable interpretation. Reserve clarification requests for critical ambiguities only.
Judgment principle: You are expected to read the codebase, understand the architecture, reason about root causes, and choose the right fix. Do not implement band-aids. Fix the actual problem.
If .agent-fox/steering.md exists in the project root, read it and follow any
directives it contains before proceeding. These project-level directives apply
to all agents and skills working on this project.
Validate that $ARGUMENTS is a valid GitHub issue URL.
The URL must match this pattern exactly:
https://github.com/{owner}/{repo}/issues/{number}
Validation regex: ^https://github\.com/([^/]+)/([^/]+)/issues/(\d+)$
Extract and remember these three values for all subsequent steps:
owner — the GitHub organisation or userrepo — the repository namenumber — the issue number (as an integer)Halt immediately. Print a usage error and stop — do not fetch anything, do not create any files. Display:
❌ Invalid GitHub issue URL: "{url}"
Usage: /af-fix https://github.com/{owner}/{repo}/issues/{number}
Example: /af-fix https://github.com/acme/widgets/issues/42
Print progress:
[af-fix] Fetching issue #{number} from {owner}/{repo}...
Run:
gh issue view {number} --repo {owner}/{repo} --json title,body,labels,author,comments,url
If the gh command fails, halt immediately and display the gh error
output verbatim, followed by:
❌ Failed to fetch issue. Check:
• Is the gh CLI authenticated? Run: gh auth status
• Does the issue exist? Verify the URL in a browser.
• Do you have access to this repository?
Do not proceed if the issue fetch fails.
Store the following in working memory:
title — issue titlebody — issue body (markdown)labels — list of label namesauthor — issue author logincomments — list of comment bodiesurl — the canonical issue URLScan the issue body and all comment bodies for URLs matching:
https://github.com/{owner}/{repo}/pull/{pr_number}
For each linked PR, fetch:
gh pr view {pr_number} --repo {owner}/{repo} --json title,body,files
Store PR context (title, body, changed files) for use in analysis. If a linked PR fetch fails, note the gap and continue.
Before analyzing the issue, orient yourself in the repository.
Print progress:
[af-fix] Analyzing codebase...
Read these files if they exist:
README.mdprd.md or .agent-fox/specs/prd.mdAGENTS.md or CLAUDE.mdRun:
ls -la
git log --oneline -20
git status --short --branch
Explore key source files, understand the module structure, how components interact, and what testing framework and conventions the project uses.
Run the project's test suite to establish a green baseline:
make test
Or the project-appropriate equivalent (e.g., uv run pytest, npm test,
cargo test). Record the results. If tests fail, note the failures — they
become part of the context for understanding the issue.
This is the most critical step. Think deeply about the problem before writing any code.
Print progress:
[af-fix] Analyzing issue #{number}: {title}...
Determine the issue type from labels, title, and body:
| Classification | Indicators |
|---|---|
| Bug / regression | Labels: bug, fix, regression; body mentions "expected vs actual", stack traces, error messages |
| Feature request | Labels: enhancement, feature, feat; body describes new capability |
| Refactor | Labels: refactor, tech-debt; body describes structural improvement |
| Performance | Labels: performance, perf; body mentions latency, throughput, memory |
If the issue is a bug or regression:
If the issue is a feature request or refactor:
Only ask for clarification when ALL of the following are true:
If clarification is needed, post a comment to the issue:
gh issue comment {number} --repo {owner}/{repo} --body "{clarification_request}"
Format the clarification request as:
## Clarification Needed
I'm working on this issue and need clarification before proceeding:
**Question:** {specific question}
**Interpretation A:** {description} → would lead to {approach A}
**Interpretation B:** {description} → would lead to {approach B}
I cannot determine the correct interpretation from the codebase or issue
context. Which approach is correct?
Then halt and wait for the user to respond. Do not proceed until clarification is received.
In all other cases — minor ambiguities, style choices, implementation details — use your best judgment and proceed. Record your reasoning in the issue comment (Step 5).
Post a structured comment to the issue explaining your diagnosis and planned approach. This creates a transparent audit trail before any code changes.
Print progress:
[af-fix] Posting analysis to issue #{number}...
## Analysis
> Auto-generated by `af-fix`. Reviewing issue context and codebase.
### Diagnosis
**Classification:** {bug | feature | refactor | performance}
**Root Cause / Problem:**
{1-3 paragraph explanation of what the issue is and why it occurs. For bugs,
explain the root cause. For features, explain the gap. Reference specific
files, functions, and line ranges.}
### Planned Fix
**Approach:**
{1-3 paragraph explanation of how you will fix it. Reference specific modules,
functions, and the nature of the changes. Explain why this approach is correct.}
**Files to modify:**
- `{path/to/file.py}` — {what changes and why}
- `{path/to/test_file.py}` — {what tests to add or update}
**Assumptions:**
{List any assumptions you made when the issue was ambiguous. Explain your
reasoning for each.}
---
*Analysis by `af-fix`. Implementation follows.*
gh issue comment {number} --repo {owner}/{repo} --body "{analysis_comment}"
If posting fails, print the comment text to the terminal so the user can post it manually. Continue to Step 6 regardless — this is a non-fatal failure.
git status --porcelain
If the output is non-empty, halt immediately:
❌ Working tree has uncommitted changes. Please commit or stash before running
af-fix:
git stash
git commit -am "WIP"
Then re-run: /af-fix {url}
From the issue title, derive a branch name:
a an the for with of to in is fix add bug featureConstruct: fix/issue-{number}-{slug} (for bugs) or
feature/issue-{number}-{slug} (for features/refactors)
git ls-remote --heads origin {branch_name}
If the branch already exists on origin, halt and warn:
⚠️ Branch {branch_name} already exists on origin.
Overwrite? This will force-push to the existing branch.
Do not proceed until the user confirms.
git checkout -b {branch_name}
Print:
[af-fix] Created branch {branch_name}
Follow the coding workflow from _templates/prompts/coding.md. Adapt the
spec-driven steps to the issue context.
Print progress:
[af-fix] Implementing fix for issue #{number}...
State explicitly:
Test-first approach. Before changing implementation code:
If the issue is a bug, write a regression test that:
If the fix changes user-facing behavior, public APIs, configuration, or architecture:
docs/adr/ if the fix involves a design decisionRun all quality checks:
make check
Or the project-appropriate equivalent. All of the following must pass:
If any check fails, fix the failure before proceeding. Do not move to Step 8 with failing checks.
After the fix is implemented and all quality gates pass, post a summary comment to the issue.
Print progress:
[af-fix] Posting fix summary to issue #{number}...
## Fix Implemented
> Auto-generated by `af-fix`.
### Summary
{1-3 sentence summary of what was done.}
### Changes
| File | Change |
|------|--------|
| `{path}` | {brief description} |
| ... | ... |
### Tests
- {test file}: {what it tests}
- ...
### Verification
- All existing tests pass: ✅
- New tests pass: ✅
- Linter / formatter: ✅
- No regressions: ✅
### Branch
`{branch_name}` — ready to merge into `develop`.
---
*Fix by `af-fix`. Ready for review.*
gh issue comment {number} --repo {owner}/{repo} --body "{summary_comment}"
If posting fails, print the comment text to the terminal. Continue regardless.
Commit the changes, push the feature branch, create a pull request, and merge
into develop.
git add -A
git commit -m "{type}({scope}): {description} (fixes #{number})"
Use conventional commits:
fix(scope): for bug fixesfeat(scope): for featuresrefactor(scope): for refactorsperf(scope): for performance improvementsgit push -u origin {branch_name}
If the push fails, retry up to 3 times with exponential backoff (2s, 4s, 8s).
Log each retry:
[af-fix] Push failed, retrying in {delay}s (attempt {n}/3)...
If all retries fail, print the error and continue — the PR cannot be created without a pushed branch, so skip Step 9.3 as well.
Create a PR targeting develop that links to the original issue. The Closes
keyword ensures the issue is automatically closed when the PR merges.
gh pr create --repo {owner}/{repo} \
--base develop \
--head {branch_name} \
--title "{type}({scope}): {description} (fixes #{number})" \
--body "{pr_body}"
PR body:
## Summary
{1-3 sentence summary of the fix.}
Closes #{number}
## Changes
| File | Change |
|------|--------|
| `{path}` | {brief description} |
| ... | ... |
## Tests
- {test file}: {what it tests}
- ...
## Verification
- All existing tests pass: ✅
- New tests pass: ✅
- Linter / formatter: ✅
- No regressions: ✅
---
*Auto-generated by `af-fix`.*
Print progress:
[af-fix] Created PR #{pr_number}: {pr_url}
Store pr_number and pr_url for the completion summary.
If PR creation fails for any reason, print a warning and continue:
⚠️ Failed to create PR. Push the branch manually and create a PR via:
gh pr create --base develop --head {branch_name} --title "..."
git checkout main
git pull origin main
git merge --squash {branch_name}
# Use the feature branch tip commit's message — never use --no-edit
# (it produces "Squashed commit of the following:" noise)
git log -1 --format=%B {branch_name} | git commit -F -
If the merge produces conflicts:
git push origin main
If the push fails, retry up to 3 times with exponential backoff (2s, 4s, 8s).
If all retries fail:
⚠️ Push failed after 3 attempts. Changes are merged locally on develop.
Push manually: git push origin develop
git status --short --branch
Confirm the working tree is clean and develop is up to date.
Print a final summary:
[af-fix] ✅ Issue #{number} fixed and merged to develop.
Issue: {title}
Branch: {branch_name}
PR: {pr_url, or "not created"}
Commit: {commit_hash}
Files: {N} files changed
Tests: {M} tests added/modified
Warnings: {any warnings, or "None"}
This completes the af-fix workflow. Do not perform any additional actions after printing this summary.