← All posts
Deep Dive

The Script Generator: From Prompt to Production-Quality NetOps Code

Describe the operation in plain English, pick the vendor and constraints, and the generator returns a script with parsers, validators, and a form.

NAPT Team8 min read
Script generatorprompt…

The Script Generator is the on-ramp to the rest of the platform. The Streaming Console runs scripts; the RCA engine reasons over their findings; Compliance uses their parsers. The bottleneck has always been author-time: writing a parser-equipped, vendor-aware, parameter-driven script is hours of careful work for an experienced engineer and weeks for someone learning.

The generator collapses that to minutes without lying about what it produced.

The prompt is the spec

You describe what the script should do — "check OSPF adjacencies on every distribution router and flag neighbours not in Full state". The configure tab adds the structured constraints: vendor, OS family, inputs, expected outputs, and any safety flags. The combined spec becomes the prompt; the AI produces a candidate.

What the generator actually returns

A generated script is a bundle, not a single file:

  • The executable script body itself, vendor-correct and idiomatic.
  • A parser that converts raw output into typed findings.
  • A parameter schema so the console renders the right input form.
  • A short runbook describing what the script does and when to use it.
  • Validation tests that exercise the parser against captured sample output.

Validation is part of generation

Every generated script is run through scriptValidator before it is shown to you. The validator checks for the things AI models get wrong: shadowed variables, missing error handling, unbounded loops, and finding shapes that do not match the schema. Failures are surfaced inline, not hidden behind an "trust me" generation step.

A script that does not validate is not shipped to the script library. The platform would rather show you two solid scripts than ten plausible ones.

Refinement loop

The Refine tab is where most of the real work happens. You read the candidate, find the part that is almost right, and ask for the targeted change. Refinement uses a smaller faster model with the script and the diff history in context, so iterations cost less than a fresh generation.

Templates and history

Frequently-used patterns become templates: parameterised starting points the generator fills in. The history tab keeps every generation, including the prompts and validator output, so you can re-run a successful generation against a new vendor in one click.

Why we did not just hand you a chat box

A generic chat could write a script. It could not write a script that the rest of this platform knows how to run. The generator's job is to enforce the contract: every output must produce findings the RCA engine can read, parameters the console can render, and metadata the compliance and intent engines can consume. The boring infrastructure is the point.

Tips for great generations

  • Specify the vendor before describing the operation — generations that lead with the operation tend to drift across CLI dialects.
  • Provide a sample of expected output if you have one. Parsers improve dramatically when they have a target.
  • Ask for the smallest useful script first; refine into the bigger one. Diffs are cheaper than rewrites.

What to try first

Generate a read-only script for a check you already do by hand. Run it through the console. Watch the findings show up in the rest of the panels. The platform clicks into focus the moment the first generated script produces evidence the rest of it can use.

#generator#ai#scripts

Was this helpful?

Generate scripts for the task covered in this post

Describe what you need and NAPT writes production-ready automation in Netmiko, NAPALM, or Nornir.

Open Script Generator →
New to NAPT? Start with the Setup Guide

Related posts