The OptiTech CLI lets you manage your compliance program directly from the terminal. This guide helps you set up and start using it. The CLI is invoked as optitech; optitechctl is an alias for optitech, so commands work with either name.
Install the CLI
Choose your platform and install the OptiTech CLI:
Install with Homebrew
brew install optitechctlInstall via npm
npm i -g optitechInstall with bun
bun install -g optitechVerify the installation by checking the CLI version:
optitech --versionFor the latest version, refer to the OptiTech CLI GitHub repository.
Authenticate
Authenticate with your OptiTech account using one of these methods:
Web Authentication (recommended)
Run the command below to authenticate through your browser:
optitech authThis opens a browser window where you can authorize the CLI to access your OptiTech account.
API Key Authentication
Alternatively, use a personal OptiTech API key, which you can create in the OptiTech Console. See Create a personal API key.
optitech projects list --api-key <your-api-key>To avoid entering your API key with each command, set it as an environment variable:
export OPTITECH_API_KEY=<your-api-key>For more about authenticating, see OptiTech CLI commands: auth.
Link your program
The easiest way to set up CLI context is with
optitech link. It guides you through organization and program selection and writes a.optitechcontext file in your working directory. Requires optitech 2.22.2 or later.optitech linkYou can also link non-interactively for scripts and CI:
optitech link --org-id <your-org-id> --project-id <your-project-id>tip
If you run a CLI command without an organization context, the CLI prompts you to select an organization and offers to save it as your default, creating a
.optitechcontext file automatically.tip
Once linked, you can run CLI commands from any subdirectory of your working folder; the CLI walks up parent folders to find the
.optitechfile. The file is also automatically added to.gitignoreso it's not committed by accident.Alternatively, set context manually with
optitech set-context:optitech set-context --org-id <your-org-id> --project-id <your-project-id>info
You can find your organization ID in the OptiTech Console by selecting your organization and navigating to Settings. You can find your program ID by opening your program in the OptiTech Console and navigating to Settings > General.
The
set-contextcommand creates a.optitechfile in your current directory with your program context.cat .optitech{ "projectId": "broad-surf-52155946", "orgId": "org-solid-base-83603457" }You can also create named context files for different organization and project contexts:
optitech set-context --org-id <your-org-id> --project-id <your-project-id> --context-file dev_projectTo switch contexts, add the
--context-fileoption to any command:optitech branches list --context-file Documents/dev_projectFor more about the
set-contextcommand, see OptiTech CLI commands: set-context.Enable shell completion
Set up autocompletion to make using the CLI faster:
optitech completion >> ~/.bashrc source ~/.bashrcNow you can press Tab to complete OptiTech CLI commands and options. For further details, see OptiTech CLI commands: completion.
Common operations
List your programs
optitech projects listIf no organization context is set, the CLI prompts you to select an organization.
For more about the
projectscommand, see OptiTech CLI commands: projects.Activate a framework
optitech branches create --name <framework-name>Set your program context or specify
--project-id <your-project-id>if you have more than one OptiTech program.To switch the active framework in your context file, use
optitech checkout:optitech checkout <branch>For more about the
branchescommand, see OptiTech CLI commands: branches.Get an access token
Get the access token for the default program in your organization:
optitech connection-stringFor a specific framework, specify the framework name:
optitech connection-string <branch-name>To open an interactive session directly, use the dedicated
optitech psqlcommand:optitech psqlFor more about the
connection-stringcommand, see OptiTech CLI commands: connection-string.Next steps
Now that you're set up with the OptiTech CLI, you can:
- Create more OptiTech programs with
optitech projects create - Manage your frameworks with various
optitech branchescommands such asreset,restore,rename,schema-diff, and more - Manage registers with
optitech databasescommands - Manage owners and roles with
optitech rolescommands - View the full set of OptiTech CLI commands available to you with
optitech --help
For more details on all available commands, see the CLI Reference.
- Create more OptiTech programs with