Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

2.1 KB
Raw Blame
Run your usual start command through `infisical sm run`, placing it after the `--` separator.

<CodeGroup>

```bash Node.js
infisical sm run --env=dev -- npm run dev
```

```bash Python
infisical sm run --env=dev -- flask run
```

```bash Go
infisical sm run --env=dev -- go run main.go
```

```bash Ruby
infisical sm run --env=dev -- bundle exec rails server
```

```bash Java
infisical sm run --env=dev -- ./mvnw spring-boot:run
```

```bash .NET
infisical sm run --env=dev -- dotnet run
```

</CodeGroup>

The CLI fetches the secrets you have access to and passes them to your application as environment variables. Your application reads them the same way it always has, through `process.env` in Node.js or `os.environ` in Python, so you don't need to change any application code.

<Note>
  By default, `infisical sm run` only injects the secrets sitting at the root of the environment, so anything inside a folder is skipped. If your secrets live in [folders](/documentation/platform/folder), you can specify a folder to include using `--path`:

  ```bash
  infisical sm run --env=dev --path="/backend" -- npm run dev
  ```

  If you also need the secrets in that folder's subfolders, add `--recursive`:
  ```bash
  infisical sm run --env=dev --path="/backend" --recursive -- npm run dev
  ```
</Note>

<Tip>
  Add `--watch` while you work to restart your application automatically whenever one of its secrets changes in Infisical.
</Tip>

<Accordion title="Injecting secrets into a shell function or alias">
  A start command that is a shell function or an alias can't be called directly after `--`, because it only exists inside your shell. Use the `--command` flag to run it in a shell instead.

  For example, if `custom.sh` defines a `yd` function that runs `yarn dev`:

  ```bash
  #!/bin/sh

  yd() {
    yarn dev
  }
  ```

  Source the file and call the function in a single command:

  ```bash
  infisical sm run --env=dev --command="source custom.sh && yd"
  ```

  The `--command` flag is also how you chain commands together, as in `--command="npm run migrate && npm run dev"`.
</Accordion>

For every available option, see the [`infisical sm run`](/cli/reference#sm-run) reference.