{
  "jimothyPipeline": 1,
  "name": "Closed-lost debrief",
  "description": "Works out why a deal was lost, files the reason in your CRM, and sets a date to re-engage.",
  "icon": "rocket",
  "color": "#0369a1",
  "repo": {
    "mode": "scratch"
  },
  "concurrency": 3,
  "variables": {
    "reasons": "price, missing feature, competitor, timing, no decision, champion left, poor fit",
    "crmWebhookUrl": "",
    "slackWebhookUrl": ""
  },
  "steps": [
    {
      "id": "debrief",
      "name": "Write debrief",
      "type": "agent",
      "description": "Reads the deal history and picks the loss reason, with evidence, lessons and a re-engage date.",
      "harnessId": "anthropic-api",
      "model": "claude-opus-5",
      "timeoutMinutes": 10,
      "passPattern": "^\\s*REASON:\\s*\\S",
      "prompt": "Deal {{issue.key}}: {{issue.title}}, {{issue.raw.amount | default:\"amount unknown\"}}, owner {{issue.raw.owner | default:\"unknown\"}}, competitor {{issue.raw.competitor | default:\"none recorded\"}}.\n\nHistory:\n{{issue.description | truncate:60000}}\n\nWrite a closed-lost debrief. Start with exactly one line \"REASON: <one of: {{vars.reasons}}>\", then the line \"*Closed lost: {{issue.title}}* ({{issue.raw.amount | default:\"amount unknown\"}})\". Then:\n*Evidence*: two or three quotes or facts from the history that show it\n*What would have changed it*: specific, about our process or product, not the buyer\n*Re-engage*: a month and the trigger to watch for, or \"Don't\" with why\n*Lesson for the team*: one sentence\nBase everything on the history; say when it doesn't support a conclusion."
    },
    {
      "id": "crm",
      "name": "Update CRM",
      "type": "shell",
      "description": "Sends the reason and debrief to your CRM.",
      "dependsOn": [
        "debrief"
      ],
      "timeoutMinutes": 2,
      "command": "printf '{\"deal\":%s,\"reason\":%s,\"debrief\":%s}' {{issue.key | json}} {{steps.debrief.output | first_line | json}} {{steps.debrief.output | json}} | curl -fsS -X POST -H 'Content-Type: application/json' --data @- {{vars.crmWebhookUrl}}"
    },
    {
      "id": "post",
      "name": "Post to Slack",
      "type": "shell",
      "description": "Posts the debrief to the sales channel.",
      "dependsOn": [
        "debrief"
      ],
      "timeoutMinutes": 2,
      "command": "printf '{\"text\":%s}' {{steps.debrief.output | json}} | curl -fsS -X POST -H 'Content-Type: application/json' --data @- {{vars.slackWebhookUrl}}"
    }
  ]
}