# The Fig CLI

## **Fig CLI Structure**

Fig's CLI makes it easy to access apps, commonly used files ([like interactive runbooks](/fig/interactive-runbooks-2.md)), and commonly used scripts.&#x20;

#### **The general syntax for Fig commands is:**

`fig <command, app name, or file name> [subcommands] [inputs]`

#### Below

1. **CLI Hierarchy** explains how Fig parses and routes every command it receives
2. **Examples** gives some examples CLI commands and how Fig would route them

{% hint style="info" %}
**Remember:** Fig commands can **display** websites, fig apps, interactive runbooks (.run files). and **execute** scripts
{% endhint %}

## CLI Hierarchy

Fig follows a specific hierarchy when determining how to parse any given command. Fig has a hierarchy to avoid conflicts. For example, `fig deploy` could refer to an app named *deploy* and a script in your $FIGPATH named *deploy.*

**Let's say you run** `fig CMD`. Fig will check (in this order):

1. [**Fig Overrides**](/fig/the-fig-cli/fig-overrides.md)
   * Is `CMD` a native Fig command that can't be overridden?
2. [**Fig Aliases**](/fig/the-fig-cli/fig-aliases.md)
   * Have you defined a custom Fig Alias for `CMD`?
3. [**$FIGPATH**](/fig/the-fig-cli/figpath.md)&#x20;
   * Is there a **file** like [`CMD.fig`](/fig/build-a-cli.md), `CMD/index.html`, [`CMD.run`](/fig/interactive-runbooks-2.md), `CMD.html` or an **executable** like `CMD`, `CMD.sh`, `CMD.py`, or `CMD.js` in any of the directories you have specified in your $FIGPATH
   * For help setting up your $FIGPATH, go to [Settings](/fig/get-started/fig-home/settings.md)
4. [**Fig Apps**](/fig/the-fig-cli/fig-apps.md)
   * Is there an App on the Fig App Store called `CMD`

## **Examples**

* `fig dir` --> Opens the dir app
* `fig google hello world` --> Opens the Google app and searches "hello world"
* `fig run heroku`--> Opens the interactive runbook, heroku[.run](/fig/interactive-runbooks-2.md), located in your current working directory
* `fig web https://github.com/pulls` --> Open your Pulls page in Github
* `fig local index.html` --> Opens the index.html file in your current working directory
* `fig deploy --flag` --> Runs the deploy.sh script and passes in a flag
* `fig acme forkdb` --> Runs the forkdb subcommand specified by your acme[.fig](/fig/build-a-cli.md) file

{% hint style="info" %}
**Hint:** Just running `fig` gives you a list of all the subcommands you have available.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://fig.gitbook.io/fig/the-fig-cli.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
