Skip to content

The circuit command ​

Run circuit alone for a menu, or run a command straight away, such as circuit validate. If you leave out an argument, such as the device, Circuit asks for it.

The menu circuit opens: Core, Utilities, Secrets, and Circuit, each with its commands.┌ Circuit 1.2.1◆ What do you want to do?│ ── Core ──│ ● Validatecheck the whole project│ ○ Diffshow what would change on a device│ ○ Applymake a device match its config│ ── Utilities ──│ ○ Executerun read-only commands on a device│ ○ BGPshow a device's BGP sessions│ ○ Access consoleopen a device's serial console│ ○ Communitieswhat each BGP community means│ ○ Addressesused and free address space│ ○ Syncupdate NetBox, LibreNMS, PeeringDB, or Prometheus│ ○ Studioopen the project in your browser│ ○ Renamerename a device everywhere in the project│ ○ Tidy filesfix spacing and line breaks│ ── Secrets ──│ ○ Secretsedit the secrets in a text editor│ ── Circuit ──│ ○ Update Circuit│ ○ Uninstall Circuityour projects stay│ ○ Exit
  • Circuit works on the project in the current folder, or in the nearest parent folder that has a circuit.ts.
  • circuit <command> --help lists a command's options.
  • Without a terminal, Circuit asks nothing. See Run in CI.

Core ​

CommandDoes
validateChecks the whole project. Touches no device.
diff [device]Reads the device and shows what would change. Sends nothing. Exits 1 if something would change.
apply [device]Shows the same plan, then sends it once you say yes. See Make a change.
OptionForDoes
--confirmapplySends without asking.
--secretsapply, diffSends every secret again. Use it to change a password, because devices never show passwords.
--rollback <minutes>applyRouterOS, Junos, and FortiOS: how long before the device undoes the change if Circuit can't log back in. Default 10.
--forceapplySends even when the path check fails.
--consoleapply, diffGoes through the serial console on a jump host instead of SSH.
--experimentalvalidate, diff, applyLets a field marked 🧪 in the feature matrix through, as a warning. Test it yourself.

Utilities ​

CommandDoes
exec [device] [command...]Runs read-only commands on the device. Also execute.
bgp [device]Shows each BGP neighbor next to its live session.
access-console [device] [line...]Opens the device's serial console, already logged in.
communities [network]Prints what each BGP community means, for a looking glass.
addresses [prefix]Shows what address space is used, and what is free.
sync [target]Updates NetBox, LibreNMS, PeeringDB, or Prometheus to match the project.
studioOpens Circuit Studio in your browser. For its options, see Studio.
rename [device] [new-name]Renames a device everywhere in the project.
fmt [file...]Tidies spacing and line breaks. Nothing else changes.

exec ​

sh
circuit exec edge-01 '/ip route print where dst-address=0.0.0.0/0'
circuit exec edge-01 --file look.txt

Circuit refuses any command that could change the device, before it connects.

PlatformAllowed
RouterOSprint, monitor, ping, traceroute, torch, export, and the like
VRPdisplay ...
Raisecom ROSshow ...
Junosshow ...
FortiOSshow ..., get ..., and read-only diagnose / execute, like execute ping
OptionDoes
--file <path>Also runs each line of this file. Blank lines and lines that start with # are skipped.
--timeout <seconds>How long each command may take. Default 90.
--consoleGoes through the serial console on a jump host instead of SSH.

Secrets in the output show as <redacted>. In Git Bash on Windows, set MSYS_NO_PATHCONV=1 first, or /ip ... turns into a Windows path.

bgp ​

RouterOS only for now.

sh
circuit bgp edge-01
circuit bgp edge-01 --neighbors hurricane --wait   # wait until it's up
circuit bgp edge-01 --log 10                       # plus 10 minutes of BGP log
┌────────────────────┬───────┬──────────┬──────────────┬─────────────┬──────────────────────────────────────┐
│ Neighbor           │ State │ Prefixes │ Uptime       │ Remote      │ Why                                  │
├────────────────────┼───────┼──────────┼──────────────┼─────────────┼──────────────────────────────────────┤
│ hurricane-electric │ up    │   987654 │ 1w2d03:04:05 │ 203.0.113.1 │                                      │
│ de-cix-rs-v4       │ DOWN  │        0 │ -            │ 192.0.2.1   │ limit exceeded: over 100000 prefixes │
└────────────────────┴───────┴──────────┴──────────────┴─────────────┴──────────────────────────────────────┘
1/2 up
OptionDoes
--neighbors <regex>Shows only the neighbors whose name matches this regular expression.
--wait [count]Reads again every 15 seconds until every neighbor shown is up, or count of them. Exits 1 if time runs out.
--max <seconds>How long --wait waits at most. Default 600.
--log [minutes]Also prints the device's BGP log of the last minutes. Default 5.
--clear-limitClears the sessions that closed on their prefix limit. If several closed at once, look for a leak upstream first.

access-console ​

sh
circuit access-console core-01                            # interactive, Ctrl-] to leave
circuit access-console core-01 'display interface brief'  # send a line, print the answer
  • @wait=N: before a line waits for N quiet seconds. @if=TEXT=> sends the line only if the last output ends with TEXT.
  • --raw skips the login, such as for a boot menu.
  • Circuit doesn't check these lines as exec does, so a line can change the device.

communities ​

sh
circuit communities                 # NLNOG's community,description lines
circuit communities --format alice  # Alice-LG's [bgp_communities] section
circuit communities --format json   # the IETF YANG model's JSON
circuit communities > as64500.txt   # into a file

If several networks have communities, give the network.

FormatFor
nlnogThe NLNOG Looking Glass's communities/asNNN.txt, which bgp.tools reads too. nnn is any number, and $0 is what it matched.
aliceThe [bgp_communities] section of an Alice-LG config. * is any number, and $2 is the third part.
jsondraft-ietf-grow-yang-bgp-communities, which the NLNOG Looking Glass also reads from a URL.

addresses ​

sh
circuit addresses                   # the space your networks own, what uses it, and what is free
circuit addresses 198.51.100.0/24   # only inside this prefix
circuit addresses --length 29       # the free /29s instead
circuit addresses --format json     # for a script

Your space is each prefix in circuit({ prefixes }) and in a device's originated_prefixes. Addresses used outside your space come last.

198.51.100.0/24, prefixes ours.v4 in circuit.ts, originated by edge-01
  198.51.100.8/29, 5 free, next 198.51.100.10
      198.51.100.9  edge-01 netflix-internet
  free: 198.51.100.0/29, 198.51.100.16/28, 198.51.100.32/27, 198.51.100.64/26, 198.51.100.128/25

It reads only the project, so it doesn't know addresses a device gave out, such as DHCP leases.

sync ​

sh
circuit sync netbox               # shows what would change in NetBox, then asks
circuit sync librenms --confirm   # sends without asking

The target is netbox, librenms, peeringdb, or prometheus. See How sync works.

rename ​

sh
circuit rename edge-01 edge-02
  1. Circuit shows every line that has exactly "edge-01", such as its name and links to it.
  2. It asks whether to rename edge-01.ts too. Yes is the default, and imports follow.
  3. It lists lines that mention edge-01 inside other text, such as a description. Those are yours to change.
  4. It writes the changes once you say yes.
OptionDoes
--fileRenames the device's file too.
--no-fileKeeps the file's name as it is.
--confirmWrites without asking.

Then run circuit apply edge-02, so the device gets its new hostname.

fmt ​

sh
circuit fmt              # every .ts file of the project
circuit fmt --check      # changes nothing, and fails if a file needs tidying

Both circuit fmt and VS Code's Prettier extension read the style from .editorconfig: 4 spaces, lines up to 140 characters, LF line endings. A .prettierrc.json, if you add one, goes on top.

Secrets ​

Each secrets command works on .circuit/secrets, or on another file with --file <path>. See Secrets.

CommandDoes
secretsIn a terminal, the same as secrets edit. Without one, the same as secrets list.
secrets editOpens every secret, decrypted, in a text editor in the terminal.
secrets listLists every secret and how it is stored, and the ones the config needs but the file lacks. Shows no values.
secrets get [name]Prints one secret, decrypted.
secrets set [name] [value]Adds or changes a secret. Leave out the value to type it hidden, or your shell history keeps it. An op:// value keeps it in 1Password.
secrets delete [name]Deletes a secret. --confirm skips the question.
secrets encryptEncrypts every value typed into the file in plain text.
secrets passwordChanges the password of the secrets file. Every value is encrypted again, and the old password stops working.
secrets forgetForgets every secret that Circuit remembers for a while.
secrets password optionDoes
--1password <reference>Reads the password from 1Password from now on, such as op://Network/Circuit/password.
--forget-1passwordStops reading the password from 1Password. Circuit asks for it again.
--confirmChanges it without asking, to the value of CIRCUIT_SECRETS_NEW_PASSWORD.

Circuit itself ​

CommandDoes
new [folder]Starts a project. --full makes a full install. See Start a project.
updateMoves the project to a newer version you pick. Outside a project, or with --app, updates Circuit itself. See Updating.
uninstallRemoves Circuit from this machine. Your projects stay.
migrate <v0-folder>Converts a Circuit 0.x project, with its packages installed, to v1. Its MIGRATION.md lists what didn't move.

update and uninstall take --confirm to go ahead without asking. update --confirm takes the newest version.

migrate optionDoes
--out <folder>An empty folder for the v1 project. Default <v0-folder>-v1.
--config <file>The 0.x config file in that folder. Default circuit.config.ts.
--yesCopies the 0.x project's .env into the secrets without asking. The password comes from CIRCUIT_SECRETS_PASSWORD.

Released under the Business Source License 1.1.