n8n-development
n8n Development Skill
This skill provides comprehensive guidance for developing, testing, and maintaining n8n webhook workflows integrated with Python services. It includes patterns for building composable workflows, template development, test-driven development practices, and complete development workflows.
When to Use This Skill
Apply this skill when:
- Building new n8n webhook workflows
- Integrating n8n workflows with Python services
- Writing tests for workflow integrations
- Creating reusable workflow templates
- Debugging workflow execution issues
- Setting up development environments for n8n projects
- Following best practices for async patterns and error handling
Core Development Principles
Test-Driven Development
- Start with a failing test to define expected behavior
- Implement minimal code to make the test pass
- Refactor while keeping tests green
- Run tests with
uv run pytest
Workflow Development Process
- Design the webhook contract (request/response schema)
- Implement in n8n with error handling
- Export JSON to
nathan/workflows/[category]/ - Add to registry (
workflow_registry.yaml) - Write integration tests in
tests/workflows/[category]/ - Document with usage examples
Template Development
- Define variables using
${VAR_NAME}syntax - Add validation via schema in template frontmatter
- Test rendering using CLI
- Document with usage examples in comments
Essential Commands
# Core development
uv sync # Install dependencies
uv run pytest # Run tests
uv run pytest --cov=nathan --cov-report=term-missing # With coverage
uvx ruff check . # Lint
uvx ruff format . # Format
# n8n development
docker compose -f docker-compose.n8n.yml up -d # Run n8n locally
uv run python -m nathan.scripts.n8n_workflow_registry --help # Registry CLI
uv run python -m nathan.templating --help # Template CLI
Testing Guidelines
Test structure should mirror source in tests/ directory with descriptive naming (test_trigger_workflow_with_valid_parameters). Use pytest fixtures for shared setup and mock external dependencies. Target 80%+ test coverage.
Validation and Schemas
Use Pydantic models for API requests/responses and SQLModel for database models. Implement input validation at boundaries (API endpoints, CLI arguments) with clear, actionable error messages.
Async Patterns
Use httpx for all HTTP calls with proper timeout handling. Always use try/except for HTTP calls and async with context managers for HTTP clients. Use asyncio.gather() for parallel operations.
Reference Documents
Load these reference files when needed for specific tasks:
- Common Patterns: Load
references/common_patterns.mdfor workflow registry, template rendering, and error handling code examples - Code Review: Load
references/review_checklist.mdbefore submitting code for review - CLI Commands: Load
references/cli_commands.mdfor n8n command-line operations (export, import, execute workflows) - REST API: Load
references/rest_api.mdfor n8n REST API endpoints and Python client examples - Workflow JSON: Load
references/workflow_json_structure.mdfor understanding and building n8n workflow JSON files
Commit Guidelines
Follow conventional commits format:
feat:for new featuresfix:for bug fixesdocs:for documentation changestest:for test additions/changesrefactor:for code refactoring
Make atomic commits (one logical change per commit), test before committing, and include documentation updates with code changes.