{
  "nodes": [
    {
      "id": "a0000000-0000-0000-0000-000000000001",
      "name": "Sticky Note - Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -620,
        -160
      ],
      "parameters": {
        "width": 480,
        "height": 700,
        "content": "## Turn New Jira Tickets into Claude Code, Gemini, Cursor or Codex Sessions with CloudCLI\n\n### When a Jira ticket is created, this workflow sends it to a CloudCLI cloud dev environment where an AI agent handles the implementation, then posts the results and a live session link back to Jira for review.\n\n### How it works\n1. A Jira webhook fires when a new issue is created in your project.\n2. The ticket summary and description are composed into an agent prompt.\n3. CloudCLI fetches the target environment details (including its live access URL).\n4. The AI coding agent (Claude Code, Cursor CLI, or Codex) runs the task.\n5. The agent's output, VS Code/Cursor deep links, SSH resume command, and environment URL are posted back to Jira as a comment so reviewers can pick up exactly where the agent left off.\n\n### Set up steps\n1. Install the CloudCLI verified community node from the n8n nodes panel.\n2. Connect your Jira Cloud credentials.\n3. Connect your CloudCLI API credentials (get your key at [cloudcli.ai](https://cloudcli.ai)).\n4. Select which CloudCLI environment to use in the \"Get Environment Details\" node.\n5. Customize the prompt template in \"Compose Agent Prompt\" to fit your codebase.\n\n### Requirements\n- Jira Cloud account\n- CloudCLI account with API key ([cloudcli.ai](https://cloudcli.ai))\n- A running CloudCLI environment with your repo cloned\n\n### Need Help?\n[n8n Discord](https://discord.com/invite/XPKeKXeB7d) | [n8n Forum](https://community.n8n.io/) | [CloudCLI Docs](https://developer.cloudcli.ai)"
      },
      "typeVersion": 1
    },
    {
      "id": "a0000000-0000-0000-0000-000000000002",
      "name": "Sticky Note - Step 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 500,
        "height": 360,
        "content": "## 1. Capture New Jira Ticket\n\nThe workflow triggers when a new issue is created in your Jira project. The ticket key, summary, and description are extracted for use as the agent's task.\n\nUpdate the webhook events in the Jira Trigger to match your project."
      },
      "typeVersion": 1
    },
    {
      "id": "a0000000-0000-0000-0000-000000000003",
      "name": "Sticky Note - Step 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        460,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 300,
        "height": 360,
        "content": "## 2. Compose Agent Prompt\n\nThe ticket details are formatted into a prompt for the AI agent. Customize this to include your project's coding standards, conventions, or any context the agent should know."
      },
      "typeVersion": 1
    },
    {
      "id": "a0000000-0000-0000-0000-000000000004",
      "name": "Sticky Note - Step 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        800,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 560,
        "height": 360,
        "content": "## 3. Get Environment & Run Agent\n[CloudCLI Docs](https://developer.cloudcli.ai)\n\nThe Get Environment node fetches your environment's details including its live access URL. The agent then runs the task inside that environment's isolated container.\n\nSelect your target environment in the \"Get Environment Details\" node. The agent auto-detects the project path from the environment name."
      },
      "typeVersion": 1
    },
    {
      "id": "a0000000-0000-0000-0000-000000000005",
      "name": "Sticky Note - Step 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1400,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 560,
        "height": 360,
        "content": "## 4. Post Results to Jira\n\nThe agent's result text, session duration, cost, and multiple ways to continue the session are extracted and posted back to the Jira ticket as a comment:\n\n- **Web UI** link to the CloudCLI dashboard\n- **VS Code / Cursor** deep links that open the environment directly via Remote SSH\n- **SSH command** with `claude -r` to resume the agent session from terminal\n\nReviewers pick whichever entry point they prefer and continue where the agent left off."
      },
      "typeVersion": 1
    },
    {
      "id": "a0000000-0000-0000-0000-000000000006",
      "name": "Sticky Note - Community Node",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -620,
        720
      ],
      "parameters": {
        "color": 5,
        "width": 480,
        "height": 140,
        "content": "### Community Node\nThis workflow uses the **CloudCLI** verified community node (`@cloudcli-ai/n8n-nodes-cloud-cli`). Install it from the n8n nodes panel. [Learn more](https://docs.n8n.io/integrations/community-nodes/installation/verified-install/)."
      },
      "typeVersion": 1
    },
    {
      "id": "b0000000-0000-0000-0000-000000000001",
      "name": "New Jira Issue Created",
      "type": "n8n-nodes-base.jiraTrigger",
      "position": [
        -20,
        300
      ],
      "parameters": {
        "events": [
          "jira:issue_created"
        ],
        "additionalFields": {}
      },
      "credentials": {},
      "typeVersion": 1.1
    },
    {
      "id": "b0000000-0000-0000-0000-000000000002",
      "name": "Extract Ticket Details",
      "type": "n8n-nodes-base.set",
      "position": [
        240,
        300
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "field-ticket-key",
              "name": "ticketKey",
              "type": "string",
              "value": "={{ $json.issue.key }}"
            },
            {
              "id": "field-ticket-summary",
              "name": "ticketSummary",
              "type": "string",
              "value": "={{ $json.issue.fields.summary }}"
            },
            {
              "id": "field-ticket-description",
              "name": "ticketDescription",
              "type": "string",
              "value": "={{ $json.issue.fields.description }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "b0000000-0000-0000-0000-000000000003",
      "name": "Compose Agent Prompt",
      "type": "n8n-nodes-base.set",
      "position": [
        520,
        300
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "field-prompt",
              "name": "agentPrompt",
              "type": "string",
              "value": "=You are working on Jira ticket {{ $json.ticketKey }}.\n\nTask: {{ $json.ticketSummary }}\n\nDetails:\n{{ $json.ticketDescription }}\n\nImplement the changes described above. Write clean, well-documented code. When finished, provide a summary of what was changed and any notes for the reviewer."
            },
            {
              "id": "field-keep-ticket-key",
              "name": "ticketKey",
              "type": "string",
              "value": "={{ $json.ticketKey }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "b0000000-0000-0000-0000-000000000004",
      "name": "Get Environment Details",
      "type": "@cloudcli-ai/n8n-nodes-cloud-cli.cloudCli",
      "position": [
        860,
        300
      ],
      "parameters": {
        "resource": "environment",
        "operation": "get",
        "environmentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        }
      },
      "credentials": {},
      "typeVersion": 1
    },
    {
      "id": "b0000000-0000-0000-0000-000000000005",
      "name": "Run AI Coding Agent",
      "type": "@cloudcli-ai/n8n-nodes-cloud-cli.cloudCli",
      "position": [
        1140,
        300
      ],
      "parameters": {
        "message": "={{ $('Compose Agent Prompt').item.json.agentPrompt }}",
        "provider": "claude",
        "resource": "agent",
        "operation": "execute",
        "additionalOptions": {},
        "agentEnvironmentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Get Environment Details').item.json.id }}"
        }
      },
      "credentials": {},
      "typeVersion": 1
    },
    {
      "id": "b0000000-0000-0000-0000-000000000006",
      "name": "Extract Agent Result",
      "type": "n8n-nodes-base.set",
      "position": [
        1460,
        300
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "field-result",
              "name": "agentResult",
              "type": "string",
              "value": "={{ $json.events.find(e => e.type === 'claude-response' && e.data && e.data.type === 'result').data.result }}"
            },
            {
              "id": "field-session-id",
              "name": "sessionId",
              "type": "string",
              "value": "={{ $json.events.find(e => e.type === 'session-created').sessionId }}"
            },
            {
              "id": "field-access-url",
              "name": "accessUrl",
              "type": "string",
              "value": "={{ $('Get Environment Details').item.json.access_url }}"
            },
            {
              "id": "field-vscode-url",
              "name": "vscodeUrl",
              "type": "string",
              "value": "=vscode://vscode-remote/ssh-remote+{{ $('Get Environment Details').item.json.subdomain }}@ssh.cloudcli.ai/workspace/{{ $('Get Environment Details').item.json.name.replace(/[^a-zA-Z0-9-]/g, '') }}?windowId=_blank"
            },
            {
              "id": "field-cursor-url",
              "name": "cursorUrl",
              "type": "string",
              "value": "=cursor://vscode-remote/ssh-remote+{{ $('Get Environment Details').item.json.subdomain }}@ssh.cloudcli.ai/workspace/{{ $('Get Environment Details').item.json.name.replace(/[^a-zA-Z0-9-]/g, '') }}?windowId=_blank"
            },
            {
              "id": "field-ticket-key",
              "name": "ticketKey",
              "type": "string",
              "value": "={{ $('Compose Agent Prompt').item.json.ticketKey }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "b0000000-0000-0000-0000-000000000007",
      "name": "Post Results to Jira",
      "type": "n8n-nodes-base.jira",
      "position": [
        1740,
        300
      ],
      "parameters": {
        "comment": "=*CloudCLI agent completed work on {{ $json.ticketKey }}*\n\n{{ $json.agentResult }}\n\n----\n\n*Continue this session:*\n* Web UI: [Open in CloudCLI|{{ $json.accessUrl }}]\n* VS Code: [Open in VS Code|{{ $json.vscodeUrl }}]\n* Cursor: [Open in Cursor|{{ $json.cursorUrl }}]\n* SSH + resume: ssh {{ $('Get Environment Details').item.json.subdomain }}@ssh.cloudcli.ai then run claude -r to resume session {{ $json.sessionId }}\n\n_Automated by n8n + CloudCLI_",
        "options": {
          "wikiMarkup": true
        },
        "issueKey": "={{ $json.ticketKey }}",
        "resource": "issueComment",
        "operation": "add"
      },
      "credentials": {},
      "typeVersion": 1
    }
  ],
  "connections": {
    "Run AI Coding Agent": {
      "main": [
        [
          {
            "node": "Extract Agent Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Compose Agent Prompt": {
      "main": [
        [
          {
            "node": "Get Environment Details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Agent Result": {
      "main": [
        [
          {
            "node": "Post Results to Jira",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Ticket Details": {
      "main": [
        [
          {
            "node": "Compose Agent Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "New Jira Issue Created": {
      "main": [
        [
          {
            "node": "Extract Ticket Details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Environment Details": {
      "main": [
        [
          {
            "node": "Run AI Coding Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}