The CLI is designed for a variety of secret management applications ranging from local development to CI/CD and production scenarios.

In the following steps, we explore how to use the Infisical CLI to fetch back environment variables from Infisical and inject them into your local development process.

1

Log in with the CLI

Start by running the infisical login command to authenticate with Infisical.

infisical login

If you are in a containerized environment such as WSL 2 or Codespaces, run infisical login -i to avoid browser based login

2

Initialize Infisical for your project

Next, navigate to your project and initialize Infisical.

# navigate to your project
cd /path/to/project

# initialize infisical
infisical init

The infisical init command creates a .infisical.json file, containing local project settings, at the location where the command is executed.

The .infisical.json file does not contain any sensitive data, so you may commit it to your git repository.

3

Inject environment variables

Finally, pass environment variables from Infisical into your application.

infisical run --env=dev --path=/apps/firefly -- [your application start command] # e.g. npm run dev

# example with node (nodemon)
infisical run --env=staging --path=/apps/spotify -- nodemon index.js

# example with flask
infisical run --env=prod --path=/apps/backend -- flask run

# example with spring boot - maven
infisical run --env=dev --path=/apps/ -- ./mvnw spring-boot:run --quiet

View all available options for run command here

History

Your terminal keeps a history with the commands you run. When you create Infisical secrets directly from your terminal, they’ll stay there for a while.

For security and privacy concerns, we recommend you to configure your terminal to ignore those specific Infisical commands.

FAQ