The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"name": "My workflow",
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "gitlab-webhook",
"options": {}
},
"id": "5bb1b5c4-f4ee-4208-8643-16353692c655",
"name": "GitLab Webhook",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [
592,
192
]
},
{
"parameters": {
"jsCode": "// Build Claude Code prompt from webhook and context data\nconst webhookData = $node['GitLab Webhook'].json.body;\n\n// Debug: Log webhook structure\nconsole.log('Webhook project data:', JSON.stringify(webhookData.project, null, 2));\nconsole.log('Project namespace:', webhookData.project.namespace);\n\nconst prompt = `GitLab Issue Analysis Request\n\nIssue Title: ${webhookData.object_attributes.title}\nIssue Description: ${webhookData.object_attributes.description}\nAuthor: ${webhookData.user.name}\nIssue URL: ${webhookData.object_attributes.url}\n\nPlease analyze this GitLab issue and provide helpful insights, suggestions, or solutions based on the repository context.`;\n\nconst systemPrompt = 'You are a helpful AI assistant analyzing GitLab issues. Please analyze the provided issue and repository context, then provide a concise and actionable response that would be helpful to post as a comment on the issue. Focus on practical suggestions, potential solutions, or relevant insights based on the codebase context.';\n\nreturn [{\n json: {\n prompt: prompt,\n systemPrompt: systemPrompt,\n issueTitle: webhookData.object_attributes.title,\n issueId: webhookData.object_attributes.iid,\n projectId: webhookData.project.id,\n // Debug data\n projectName: webhookData.project.name,\n namespaceName: webhookData.project.namespace?.name,\n namespacePath: webhookData.project.namespace?.path,\n projectPath: webhookData.project.path\n }\n}];"
},
"id": "85a0188f-b618-4698-b7c6-f3798bb6a650",
"name": "Build Claude Prompt",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1040,
192
]
},
{
"parameters": {
"command": "=cd /workspace/{{$env.GITLAB_REPO_NAME}} && echo '{{$node['Build Claude Prompt'].json.prompt}}' | claude -p 'You are a helpful AI assistant analyzing GitLab issues. Please analyze the provided issue and repository context, then provide a concise and actionable response that would be helpful to post as a comment on the issue. Focus on practical suggestions, potential solutions, or relevant insights based on the codebase context.'"
},
"id": "97666b7d-cad6-425a-93b3-76824a80d4fa",
"name": "Claude Code Analysis",
"type": "n8n-nodes-base.executeCommand",
"typeVersion": 1,
"position": [
1264,
192
]
},
{
"parameters": {
"jsCode": "// Handle Claude Code execution results and errors\ntry {\n const claudeOutput = $node['Claude Code Analysis'].json;\n \n // Check for execution errors\n if (claudeOutput.exitCode !== 0) {\n const errorMessage = `\u26a0\ufe0f **Analysis Error**\\n\\nThere was an issue processing this request. Please try again or contact support.\\n\\nError Details: ${claudeOutput.stderr || 'Unknown error'}`;\n \n return [{\n json: {\n analysis: errorMessage,\n success: false,\n error: true\n }\n }];\n }\n \n // Extract the analysis from stdout\n let analysis = claudeOutput.stdout;\n \n // Clean up the output if needed\n if (!analysis || analysis.trim() === '') {\n analysis = '\ud83e\udd16 **AI Analysis**\\n\\nAnalysis completed but no specific recommendations were generated. Please provide more details in the issue description.';\n }\n \n // Add timestamp and source info\n const timestamp = new Date().toISOString();\n const finalAnalysis = `\ud83e\udd16 **AI Analysis** _(Generated: ${timestamp})_\\n\\n${analysis}\\n\\n---\\n*Powered by Claude Code - Automated Issue Analysis*`;\n \n return [{\n json: {\n analysis: finalAnalysis,\n success: true,\n error: false,\n timestamp: timestamp\n }\n }];\n \n} catch (error) {\n // Handle unexpected errors\n const errorMessage = `\ud83d\udea8 **System Error**\\n\\nUnexpected error occurred during analysis: ${error.message}\\n\\nPlease contact support if this persists.`;\n \n return [{\n json: {\n analysis: errorMessage,\n success: false,\n error: true,\n errorDetails: error.message\n }\n }];\n}"
},
"id": "39c3145b-1bc3-4503-b14f-3bfa8bc1171f",
"name": "Process Analysis Result",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1488,
192
]
},
{
"parameters": {
"operation": "createComment",
"owner": "={{ $('Get Project Owner').item.json.project_owner }}",
"repository": "={{$node['GitLab Webhook'].json.body.project.name}}",
"issueNumber": "={{$node['GitLab Webhook'].json.body.object_attributes.iid}}",
"body": "={{$node['Process Analysis Result'].json.analysis}}"
},
"id": "5e707f35-b530-432b-b7e5-741f500f75e3",
"name": "Post Analysis Comment",
"type": "n8n-nodes-base.gitlab",
"typeVersion": 1,
"position": [
1936,
96
],
"credentials": {
"gitlabApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "createComment",
"owner": "={{ $('Get Project Owner').item.json.project_owner }}",
"repository": "={{$node['GitLab Webhook'].json.body.project.name}}",
"issueNumber": "={{$node['GitLab Webhook'].json.body.object_attributes.iid}}",
"body": "=\ud83d\udea8 **Analysis Failed**\\n\\nThere was an error processing this issue automatically. A team member will review it manually.\\n\\nError: {{$node['Process Analysis Result'].json.errorDetails || 'Unknown error'}}"
},
"id": "b21d63d8-99a0-458f-9fe9-c049a9211a31",
"name": "Post Error Comment",
"type": "n8n-nodes-base.gitlab",
"typeVersion": 1,
"position": [
1936,
288
],
"credentials": {
"gitlabApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"mode": "raw",
"jsonOutput": "={\n\"project_owner\": \"{{ $json.body.project.path_with_namespace .split(\"/\")[0]}}\"\n}",
"options": {}
},
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
816,
192
],
"id": "601c34dc-a1c9-4a89-856e-38207e1c2fb4",
"name": "Get Project Owner"
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 1
},
"conditions": [
{
"id": "condition1",
"leftValue": "={{ $json.success }}",
"rightValue": null,
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
},
"id": "8601974e-0928-44a7-bc07-7a6cf92b6a05",
"name": "Check Analysis Success1",
"type": "n8n-nodes-base.if",
"typeVersion": 2,
"position": [
1712,
192
]
}
],
"connections": {
"GitLab Webhook": {
"main": [
[
{
"node": "Get Project Owner",
"type": "main",
"index": 0
}
]
]
},
"Build Claude Prompt": {
"main": [
[
{
"node": "Claude Code Analysis",
"type": "main",
"index": 0
}
]
]
},
"Claude Code Analysis": {
"main": [
[
{
"node": "Process Analysis Result",
"type": "main",
"index": 0
}
]
]
},
"Process Analysis Result": {
"main": [
[
{
"node": "Check Analysis Success1",
"type": "main",
"index": 0
}
]
]
},
"Get Project Owner": {
"main": [
[
{
"node": "Build Claude Prompt",
"type": "main",
"index": 0
}
]
]
},
"Check Analysis Success1": {
"main": [
[
{
"node": "Post Analysis Comment",
"type": "main",
"index": 0
}
],
[
{
"node": "Post Error Comment",
"type": "main",
"index": 0
}
]
]
}
},
"active": true,
"settings": {
"executionOrder": "v1"
},
"versionId": "66029abb-d9fa-4514-8b38-49037dd05a57",
"meta": {
"templateCredsSetupCompleted": true
},
"id": "6rTYbRlR4Z8quA6E",
"tags": [
{
"createdAt": "2025-07-21T04:45:33.301Z",
"updatedAt": "2025-07-21T04:45:33.301Z",
"id": "beQFBvb22zrUxijy",
"name": "AI Automation"
},
{
"createdAt": "2025-07-21T04:45:33.296Z",
"updatedAt": "2025-07-21T04:45:33.296Z",
"id": "fs4xcUkS9swEmJWu",
"name": "GitLab"
},
{
"createdAt": "2025-07-21T04:45:33.303Z",
"updatedAt": "2025-07-21T04:45:33.303Z",
"id": "nWfv1t4kSskjxiM0",
"name": "Claude Code"
}
]
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
gitlabApi
About this workflow
Gitlab-Issue-Analyzer. Uses executeCommand, gitlab. Webhook trigger; 8 nodes.
Source: https://gitlab.com/huyhq8/gitlab-ai-automation/-/blob/develop/n8n/workflows/gitlab-issue-analyzer.json — original creator credit. Request a take-down →