# Managing Workflows Like Code — AI Automation with n8n

Source: https://www.geekswithgeeks.com/en/n8n-ai-automation/ops-manage-workflows

> Export, version and monitor workflows, and split big ones into sub-workflows.

## Treat workflows as assets

Workflows export as JSON, so keep them in Git (credentials are not included in exports) and review changes like code. Break big workflows into **sub-workflows** called with the Execute Workflow node, so pieces can be tested and reused. Name nodes clearly ("Fetch new orders", not "HTTP Request 3"), add sticky notes for intent, and use separate instances or projects for development and production. Watch the **Executions** list and set up the error workflow so failures are noticed.

## Export and import from the CLI

The n8n CLI can export workflows to files for Git and import them elsewhere. Flags can change between versions; run `n8n export:workflow --help` to confirm.

```bash
n8n export:workflow --all --separate --output=./workflows/
n8n import:workflow --separate --input=./workflows/
```

**Quiz:** Why split a large workflow into sub-workflows?

- [x] Smaller parts are easier to test, reuse and understand
- [ ] n8n limits workflows to 3 nodes
- [ ] Sub-workflows are always faster
- [ ] It removes the need for names

*Answer:* Smaller parts are easier to test, reuse and understand. Modular workflows are maintainable, like functions in code.
