Using AI coding assistants for network automation safely
In short: AI assistants can speed up network automation by drafting scripts, templates, regular expressions and tests, and by explaining unfamiliar code. They can also produce commands that do not exist, insecure code or logic that looks right but is wrong. Treat their output like code from a new colleague: review every line, never paste secrets or sensitive data, and test in a lab before production.
Where AI assistants help
- Drafting a first version of a script: "Python with Netmiko that collects show version from a list of devices and writes a CSV".
- Writing Jinja2 templates, YAML structures and regular expressions.
- Explaining code written by someone else, line by line.
- Writing pytest tests and documentation for existing code.
- Converting between formats or vendors' configuration styles as a starting point.
Risks
- Invented details: commands, API endpoints or library functions that do not exist, or exist only on other platforms or versions.
- Subtle logic errors: code that runs but does the wrong thing, such as applying a change to all interfaces instead of one.
- Insecure patterns: hard-coded passwords, disabled certificate checks, no error handling.
- Data exposure: pasting real configurations, IP plans or credentials into an external service may break company policy.
- Outdated information: libraries change; suggestions may use old interfaces.
A safe workflow
- Describe the task precisely: platform, OS version, library, inputs and outputs.
- Remove secrets and sensitive details from anything you share; use example addresses.
- Read and understand every line of the output. If you cannot explain it, do not run it.
- Check commands and API calls against vendor documentation.
- Run in a lab (for example Containerlab) and add tests.
- Use the normal review and change process before production.
Company policy
Follow your organisation's rules on which AI tools are approved and what data may be shared. Many companies provide enterprise tools with data protection agreements for this purpose.
Building your own skills
Use AI to learn, not just to copy: ask it why the code works, what alternatives exist and what could go wrong. Engineers who understand the code can catch the assistant's mistakes.
Real-world example: the command that did not exist
An engineer asked an assistant for a script to set interface descriptions on older switches. The generated code used a command syntax from a newer platform, which the older switches rejected, and the script did not check for errors, so it reported success. Lab testing caught the problem, and the engineer added output checks to the script.
Practice
Name two good uses of AI assistants in network automation.
Why should you not paste real configurations into an external AI tool?
What should you do before running AI-generated code in production?
Key takeaways
- AI assistants speed up drafting, explaining and testing automation code.
- They can invent commands, introduce errors and suggest insecure code.
- Never share secrets or sensitive data; follow company policy.
- Review, verify, lab test and use normal change control.
Original content written by Mohamed Fayas for FM TecHub. © 2026 FM TecHub. You're welcome to share a link to this page; please don't copy the text elsewhere without permission.