{
  "jimothyPipeline": 1,
  "name": "Bug report → engineering ticket",
  "description": "Checks for duplicates, traces a customer bug report to the code, and files a GitHub issue after you approve.",
  "icon": "bug",
  "color": "#f59e0b",
  "repo": {
    "mode": "inplace",
    "localPath": "",
    "baseBranch": "main"
  },
  "concurrency": 2,
  "variables": {
    "label": "support",
    "helpdeskWebhookUrl": ""
  },
  "steps": [
    {
      "id": "dupes",
      "name": "Search open issues",
      "type": "shell",
      "description": "Searches open GitHub issues for the same bug.",
      "timeoutMinutes": 2,
      "continueOnError": true,
      "command": "gh issue list --state open --limit 8 --search {{issue.title}} --json number,title,url --jq '.[] | \"#\\(.number) \\(.title) \\(.url)\"'"
    },
    {
      "id": "investigate",
      "name": "Trace to the code",
      "type": "agent",
      "description": "Traces the report to the code and writes an engineering-ready issue with reproduction steps and likely cause.",
      "harnessId": "claude-code",
      "model": "sonnet",
      "dependsOn": [
        "dupes"
      ],
      "timeoutMinutes": 25,
      "prompt": "A customer reported a bug (support ticket {{issue.key}}).\n\nSubject: {{issue.title}}\nReport:\n{{issue.description}}\n\nOpen GitHub issues that might be the same bug:\n{{steps.dupes.output | default:\"(none found)\"}}\n\nRead the repository in the current directory to find the code paths this report goes through. Do not modify any files and do not create branches.\n\nWrite a GitHub issue body in Markdown:\n## Summary (one sentence, in engineering terms)\n## Customer impact (who is affected and how badly; no names, emails or other personal data)\n## Steps to reproduce (from the report; mark any step you had to infer)\n## Expected vs actual\n## Likely cause (files and functions with line numbers, and your reasoning; say how confident you are)\n## Possible duplicates (from the list above, only if they really match)\n## Suggested severity (S1 to S4, with one line why)\n\nYour final answer is the issue body and nothing else.{{#if steps.approve.output}}\n\nYour previous draft was rejected with this feedback. Rewrite it:\n{{steps.approve.output}}{{/if}}"
    },
    {
      "id": "approve",
      "name": "Approve ticket",
      "type": "approval",
      "description": "Shows you the issue. Reject with a comment if it needs changes or is a duplicate.",
      "dependsOn": [
        "investigate"
      ],
      "loopBackTo": "investigate",
      "maxLoops": 3,
      "approvalMessage": "File this GitHub issue for support ticket {{issue.key}}? If it duplicates an existing issue, reject with a comment saying so.\n\n---\n\n{{steps.investigate.output}}"
    },
    {
      "id": "file",
      "name": "File GitHub issue",
      "type": "shell",
      "description": "Files the GitHub issue with your support label.",
      "dependsOn": [
        "approve"
      ],
      "timeoutMinutes": 2,
      "command": "gh issue create --title \"[Support] \"{{issue.title}} --label {{vars.label}} --body {{steps.investigate.output}}"
    },
    {
      "id": "notify",
      "name": "Link back to helpdesk",
      "type": "shell",
      "description": "Sends the issue link back to the helpdesk ticket, if you set a webhook.",
      "dependsOn": [
        "file"
      ],
      "runIf": "{{vars.helpdeskWebhookUrl}}",
      "timeoutMinutes": 2,
      "command": "printf '{\"ticket\":%s,\"issueUrl\":%s}' {{issue.key | json}} {{steps.file.output | trim | json}} | curl -fsS -X POST -H 'Content-Type: application/json' --data @- {{vars.helpdeskWebhookUrl}}"
    }
  ]
}