This is the most useful n8n workflow I have ever built...

By NeuralNine

Share:

Key Concepts

  • N8N: A workflow automation tool used to orchestrate the interaction between Slack, GitHub, and local scripts.
  • Claude Code (Headless Mode): An AI coding agent that executes code changes, commits, and pushes to repositories without a user interface.
  • GitHub Webhooks: Used to trigger N8N workflows automatically when specific events (like issue creation) occur.
  • Ngrok: A tunneling service used to expose a local N8N instance to the internet so GitHub can send webhook events to it.
  • Structured Output: A technique using OpenAI models to parse natural language (Slack messages) into specific JSON schemas (Issue Title/Body).
  • Self-Hosted N8N: Required for executing local system commands (e.g., running Python scripts and Claude Code).

1. System Architecture and Workflow

The project consists of two primary N8N workflows that function as a closed-loop autonomous coding assistant:

  • Workflow 1 (The Executor): Triggered by a GitHub issue. It executes a local Python script that clones the repository, runs Claude Code in headless mode to implement the requested changes, commits the code, pushes to a new branch, and creates a Pull Request (PR) via the GitHub CLI.
  • Workflow 2 (The Interface): Triggered by a Slack message. It uses an OpenAI agent to convert the message into a structured GitHub issue (Title/Body), creates the issue on GitHub, and notifies the user in Slack.

2. Step-by-Step Implementation

A. Environment Setup

  1. N8N Installation: Install the self-hosted version (e.g., via npm install -g n8n).
  2. Tunneling: Use ngrok http 5678 to create a public URL for the local N8N instance.
  3. Environment Variables: Launch N8N with specific flags:
    • WEBHOOK_URL: The Ngrok URL.
    • N8N_ENABLE_UNSAFE_CORE_NODES=true: Required to execute local terminal commands.
    • N8N_RUNNERS_ENABLED=true.

B. The Python Automation Script (handle_issue.py)

The script acts as the bridge between N8N and the local file system:

  1. Inputs: Accepts repository name, issue number, title, and body as command-line arguments.
  2. Git Operations: Clones the repo (if not present), checks out the main branch, pulls updates, and creates a new feature branch (claude-issue-[number]).
  3. AI Execution: Runs claude -p "fix issue #[number] [title] [body] --permission-mode accept-edits".
  4. Finalization: Adds changes, commits with the issue number, pushes to the remote branch, and uses gh pr create to open a pull request.

C. Slack-to-GitHub Integration

  1. Slack API: Create a Slack App with channels:history, channels:read, and chat:write scopes.
  2. Event Subscription: Configure the Slack App to send events to the N8N webhook URL.
  3. AI Agent: Use an OpenAI node with a JSON schema to extract issue_title and issue_body from the Slack text.
  4. GitHub Action: Use the "Create Issue" operation to post the structured data to the repository.

3. Key Arguments and Perspectives

  • Autonomous vs. Assisted: The creator emphasizes that this is not just a prompt-response tool but a "fully autonomous" agent that handles the entire lifecycle of a feature request—from communication to deployment-ready PR.
  • Non-Technical Collaboration: A primary use case is enabling non-technical team members (e.g., co-founders) to request UI changes or features via Slack, which the developer then only needs to review and merge.
  • Security/Transparency: The use of "unsafe" nodes is necessary for local execution, requiring the user to be aware of the security implications of running automated scripts on their machine.

4. Notable Quotes

  • "I'm talking about a workflow where I can talk to an AI agent via Slack or I can just create GitHub issues and then this bot takes the GitHub issue, does the changes, commits them and pushes them to GitHub and creates a pull request."
  • "The biggest issue is setting up everything so it works... wiring everything up is not really the biggest issue."

5. Synthesis and Conclusion

This project demonstrates a powerful integration of LLM-based coding agents (Claude Code) with low-code automation (N8N). By bridging Slack and GitHub through a local Python-based execution layer, the system effectively removes the friction of manual coding for minor tasks. The key takeaway is the modularity: by using GitHub issues as the "source of truth" for tasks, the system remains robust, allowing for asynchronous development where the AI handles the heavy lifting of implementation and version control.

Chat with this Video

AI-Powered

Load the transcript when you're ready to chat so the initial page stays lighter.

Related Videos

Ready to summarize another video?

Summarize YouTube Video