agentleFS
nmarques93nmarques93/jira-triage-skills/skills/ci-autofix/SKILL.md

ci-autofix

Skill0 starsChanged 4 months agoMITView on GitHub

Takes a Customer Investigation ticket key, validates it meets the autofix gate, assembles a spec from the ticket content, finds the relevant code in the connected codebase, implements a fix, runs the test suite, and opens a draft PR referencing the ticket. Posts the PR link back to Jira. Requires a code repository to be open as the workspace folder.

  • Commits and pushes

The file

Show its rules and text

We split this skill into the rules it gives an agent

22 rules. About 0 are common, 19 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈19

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Before writing any code, read any project-level standards or conventions documented in the workspace.

    line 29
  2. Distinctive:

    If all gates pass, continue.

    line 74
  3. Distinctive:

    Search the connected codebase for code related to the bug.

    line 80
  4. Distinctive:

    Read the relevant files — controller, service/context module, schema, and any associated tests.

    line 83
  5. Distinctive:

    If you cannot locate the relevant code after a thorough search, stop and say so.

    line 89
  6. Very specific:

    Write a spec file to .claude/specs/<TICKET-KEY>.md using this structure:

    line 96
  7. Distinctive:

    Do not proceed to implementation until the spec is written and coherent.

    line 130
  8. Very specific:

    Create a new branch off the repo's default branch, named fix/<TICKET-KEY>-<short-slug>.

    line 136
  9. Distinctive:

    Never commit directly to main or master.

    line 137
  10. Distinctive:

    Follow existing patterns in the codebase — naming conventions, error handling style, logging.

    line 145
  11. Distinctive:

    Write or update tests to cover the reported scenario.

    line 146
  12. Distinctive:

    Do not change the public API contract unless the ticket explicitly requires it.

    line 147
  13. Very specific:

    Commit with a message referencing the ticket key, e.g.

    line 148
  14. Distinctive:

    Run the full test suite, or at minimum the test file(s) covering the changed code plus any new test added for this fix.

    line 156
  15. Distinctive:

    If tests still fail after one retry, stop.

    line 161
  16. Distinctive:

    Create a branch with the work-in-progress code, post a comment on the Jira ticket explaining what was attempted and where it got stuck, and …

    line 162
  17. Distinctive:

    Use this PR description template:

    line 177
  18. Distinctive:

    Before posting, show the user a preview of the comment:

    line 207
  19. Distinctive:

    If the user says no, log the PR link to console output so it is not lost.

    line 220
  20. Distinctive:

    If the Jira comment in Step 9 fails to post, log the PR link to console output — the PR is more important than the comment.

    line 250
  21. Distinctive:

    If the repo has no AGENTS.md/CLAUDE.md or other documented conventions, proceed using the README, existing code patterns, and test …

    line 252
  22. Distinctive:

    Stop and explain if any of the following are true, even after passing the gate check:

    line 260

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

CI Autofix

Given a Customer Investigation ticket key, propose and open a draft fix PR without requiring a developer to start from scratch. The engineer reviews and refines the PR — they are never cut out of the loop.

This skill only runs on tickets that meet strict gate criteria. If a ticket fails any gate, it stops immediately and explains why — it does not attempt a partial fix.


Arguments

/ci-autofix <TICKET-KEY>

Example: /ci-autofix MYPROJ-123

Step 1 — Read project standards

Before writing any code, read any project-level standards or conventions documented in the workspace. Look for:

  • AGENTS.md or CLAUDE.md at the repo root
  • Any standards manifests referenced from those files
  • Relevant docs (architecture, testing, infrastructure) as listed in the project docs

Identify files relevant to the repo's tech stack and the type of change implied by the ticket. Read those files. Do not skip this step.


Step 2 — Fetch the ticket

Fetch the full Jira ticket using the provided key. Read:

  • summary
  • description (full text)
  • comments (look specifically for AI Triage and AI Enrich comments)
  • status, priority, assignee

Extract the following fields from the ticket content. If any are missing, stop at Step 3.

FieldWhere to find it
Bug classificationAI Triage comment
Confidence levelAI Triage comment
Steps to reproduceTicket description
Expected behaviourTicket description
Actual behaviourTicket description
Confirmed reproSupport team confirmation in ticket
Affected account/environmentTicket description or comments

Step 3 — Gate check

Evaluate all four conditions. If any fail, stop and explain clearly. Do not proceed.

GatePass condition
ClassificationAI Triage comment exists and classifies ticket as Bug (cluster or standalone). KB-answerable, docs-gap, and needs-investigation tickets are not eligible.
ConfidenceAI Triage confidence is High. Medium or Low confidence tickets require human judgement first.
Repro confirmedTicket has confirmed reproduction by a support team member, OR a detailed payload/trace that demonstrates the bug. "Unable to replicate" is a hard stop.
ScopeThe bug is describable by a single endpoint, a single UI component, or a single data model in the connected repo. If the description implicates multiple services, cross-service data flows, or infrastructure changes, stop and say so.

If all gates pass, continue. State which gates passed before proceeding.


Step 4 — Find the relevant code

Search the connected codebase for code related to the bug. Use the endpoint, component name, or data model from the ticket description as search terms.

Read the relevant files — controller, service/context module, schema, and any associated tests. Understand the current implementation before proposing a change.

Summarise what you found in 3–5 sentences: which files are involved, what the current behaviour is, and where you believe the bug originates. This becomes part of the spec.

If you cannot locate the relevant code after a thorough search, stop and say so. Do not guess at a fix in unfamiliar code.


Step 5 — Write the spec

Write a spec file to .claude/specs/<TICKET-KEY>.md using this structure:

# <TICKET-KEY>: <Ticket summary>

## Source
- Jira: <link to ticket>
- AI Triage: <classification and confidence from triage comment>
- Affected account: <identifier from ticket>

## Problem
<2–3 sentences describing the bug from the user's perspective>

## Root cause hypothesis
<2–3 sentences describing where in the code the bug likely originates,
based on your code reading in Step 4. Be specific about file and function names.>

## Relevant files
- `<path/to/file>` — <one line describing its role>
- (list all files read in Step 4)

## Acceptance criteria
- [ ] <Expected behaviour from the ticket is now the actual behaviour>
- [ ] <Existing tests pass>
- [ ] <New test covers the reported scenario>

## Approach
<Describe the minimal change needed. Reference specific functions or modules.
Do not over-engineer — fix the reported behaviour, nothing more.>

## Out of scope
<Anything mentioned in the ticket that is explicitly NOT being addressed in this PR>

Do not proceed to implementation until the spec is written and coherent.


Step 6 — Implement the fix

Create a new branch off the repo's default branch, named fix/<TICKET-KEY>-<short-slug>. Never commit directly to main or master.

The spec at .claude/specs/<TICKET-KEY>.md is the source of truth. Implement the change described in its Approach section directly. Do not deviate from the approach described there without updating the spec first.

Key implementation constraints:

  • Make the minimal change that fixes the reported behaviour. Do not refactor unrelated code.
  • Follow existing patterns in the codebase — naming conventions, error handling style, logging.
  • Write or update tests to cover the reported scenario. A fix without a test is incomplete.
  • Do not change the public API contract unless the ticket explicitly requires it.
  • Commit with a message referencing the ticket key, e.g. <TICKET-KEY>: <short description>.

Step 7 — Verify

Identify how this repo runs its tests — check package.json scripts, a Makefile, tox.ini/pytest.ini, or CI config under .github/workflows/, .gitlab-ci.yml, etc. Run the full test suite, or at minimum the test file(s) covering the changed code plus any new test added for this fix.

If tests fail:

  • Attempt one fix based on the failure output.
  • If tests still fail after one retry, stop. Do not push a failing build.
  • Create a branch with the work-in-progress code, post a comment on the Jira ticket explaining what was attempted and where it got stuck, and stop.

If tests pass: continue to Step 8.


Step 8 — Open the PR

Push the branch and open the PR as a draft — it is never ready to merge without engineer review. Use the gh CLI (gh pr create --draft ...) if available, or whatever Git-hosting tool/MCP is connected in this environment. If neither is available, stop after pushing the branch and report the branch name so the engineer can open the PR manually.

Use this PR description template:

## 🤖 AI-assisted fix — <TICKET-KEY>

**Source:** [<TICKET-KEY>](<jira link>) — <ticket summary>
**Classification:** <from AI Triage comment>
**Confidence:** High | Confirmed reproduced by support

This PR was generated automatically from the CI ticket using `ci-autofix`.
An engineer must review before merging. Pay particular attention to:
- Whether the root cause hypothesis in the spec is correct
- Edge cases not covered by the reproduction scenario
- Whether the test coverage is sufficient

## What changed
<1–3 sentences describing the code change>

## How to verify
<Steps to reproduce the fix locally, based on the ticket's repro steps>

## Related
- CI ticket: <link>
- Cluster siblings: <linked tickets if applicable, else omit>

Step 9 — Confirm and comment on the Jira ticket

Before posting, show the user a preview of the comment:

Ready to post the following comment to <TICKET-KEY>?

---
[preview of comment]
---

Post this comment? (yes/no)

Wait for explicit confirmation before calling addCommentToJiraIssue. If the user says no, log the PR link to console output so it is not lost.

Post a comment on the original ticket using this format:

🤖 **AI Autofix** _(AI-generated · testing phase)_ | Draft PR opened

A draft fix PR has been opened for this ticket: <PR link>

The PR is pending engineer review — it has not been merged.
Please review the implementation carefully before closing this ticket.

**Root cause:** <one sentence from spec>
**Files changed:** <list>
**Tests added:** Yes / No

---
_This PR was generated automatically by the ci-autofix skill. The system is in a testing phase — the engineer reviewing this PR is responsible for validating correctness before merge._

Guardrails

  • Never push directly to main or master.
  • Never open a non-draft PR. Every autofix PR requires human review.
  • Never proceed past Step 3 if any gate fails — explain the failure clearly.
  • Never attempt a fix if you cannot locate the relevant code (Step 4).
  • Never push if the test suite is failing (Step 7).
  • Never modify files outside the scope identified in Step 4 without updating the spec.
  • If the Jira comment in Step 9 fails to post, log the PR link to console output — the PR is more important than the comment.
  • If the repo has no AGENTS.md/CLAUDE.md or other documented conventions, proceed using the README, existing code patterns, and test structure as the source of truth. Note the gap in the spec's Approach section rather than blocking on it.

When to stop and hand off to a human

Stop and explain if any of the following are true, even after passing the gate check:

  • The root cause hypothesis requires changes to the database schema or migrations.
  • The fix requires changes to a message queue consumer or producer.
  • The relevant code is in a shared module used by more than 3 other modules.
  • The ticket description contains contradictory information about expected behaviour.
  • You are not confident in your root cause hypothesis after reading the code.

In all these cases: write the spec (Step 5) anyway, leave it in .claude/specs/, and post it to the Jira ticket (after confirmation). The spec alone is useful context for the engineer who picks it up.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.