DocsAutocompleteGuidesAutocomplete for internal scripts

Fig supports building autocomplete for internal scripts (executables) like,, or build.js. Assuming these scripts each take different arguments, subcommands, and flags, Fig can be used to build autocomplete for these scripts to make it easy for your team to use them.

Use the Autocomplete Boilerplate Template

You can clone our boilerplate repo to write and test and internal spec using our autocomplete-tools package on npm:

npx -y @withfig/autocomplete-tools init

This will create a boilerplate directory .fig/autocomplete in your current directory like our autocomplete repo but without the public specs.

Working From The Autocomplete Repo

Now that you have the boilerplate directory, you can cd into this directory with cd .fig/autocomplete and you'll have a nice developer environment set up by default.

When developing a spec, turn on Fig development mode by running npm run dev from your autocomplete folder. This should generate a src/ folder in the root of your autocomplete folder.

Development mode compiles all changes from the src/ folder into specs that can be read by Fig, and tells Fig to load specs from the build/ folder. (If you don't see build/ yet, it will be generated upon making changes to any file in src/) This means you can test your internal CLI from your terminal in real time!

Create a TypeScript file in the src/ folder for the internal command you're building for. Write your spec in this folder, and make changes in src/. All changes to files in src/ will be compiled to build/ automatically.

We write our specs in the autocomplete folder to get access to linting and live testing. Now, we need to move the compiled specs from /build into your scripts folder for usage.

Setting Up Autocomplete for Your Script

In the same directory as your scripts, create a .fig directory. The .fig directory should contain an autocomplete spec for each script you want to generate suggestions for.

From the autocomplete directory, take the compiled specs from build/ and move them into the .fig directory of your scripts directory.

Note: the naming of these specs is important! They should exactly match [script].js. If you wanted to write a spec for, name it

The folder hierarchy should look like this:

|-- tests.js
|-- .fig/
    |-- autocomplete/
        |-- src/
            |-- test.js.ts
        |-- build/
            |-- test.js.js

Your scripts directory containing .fig can be shared with teammates, who will automatically get autocomplete for these scripts if they have Fig installed. Want to get your teammates onboard? Run fig invite in your CLI!

Up Next

Looking to build comprehensive internal CLIs for your team with Fig? See Building Autocomplete for Internal CLIs.

For more information on building more complex autocomplete specs, see Building Your First Autocomplete Spec and API.