Save and Deploy your spec

Setup Fig's Development Environment

First, we need to set up Fig's developer environment.

This is quite simple, but if you want to understand more, read this guide.

Go to the root folder of your CLI tool and run the following

npx @withfig/autocomplete-tools@latest init

This will create a .fig/ folder in the root of your CLI project.

From now on, you should build and edit your completion specs in the .fig/autocomplete/src folder.

Save your spec

Use your new subcommand to generate a spec and save it to the `.fig/autocomplete/src` folder.

(Make sure you replace the occurrences of my-cli with your own CLI's name)

Test your spec

Turn on dev mode by running the following:

npm run dev

Go to a new terminal and run my-cli[space]. Suggestions for your tool will appear in Fig's autocomplete window.

Customize your spec

Customize your spec as discussed in our getting started guide.

You can do this later, but let's skip this for now.

Deploy to Fig's Cloud

This is quite simple but if you want to read more, check out Fig's Autocomplete for Team's guide.

# Create a new team
npx fig-teams@latest teams create <team>

# Add co-workers to your team
npx fig-teams@latest teams add:user <email> -t <team>   

# Compile your completion specs
npm run build

# Link your compiled completion specs to a team (use space to select / deselect)
npx fig-teams@latest manifest

# Deploy your completion specs to Fig's cloud.
npx fig-teams@latest deploy

After deploying, you and your teammates just need to restart Fig, and autocomplete for your CLI should work out of the box!

Keeping your CLI and completion spec in sync

Chances are you make regular changes to your CLI tool, e.g. you add new subcommands/options/arguments, edit descriptions etc.

Fig makes it easy to reflect these changes in your completion spec.

Our "merge tool" takes your old spec and your new one and deep merges them.

How do I do the merge

npx @withfig/autocomplete-tools@latest merge <path/to/oldSpec.ts> <path/to/newSpec.ts> --preset 

Automating this in CI/CD

You can automate the creation and deep merging of specs in your CI/CD.

cd path/to/your/cli/tool

# Compile your completion spec
cd .fig/autocomplete/
npm run build

# Deep merge new spec into old spec

# Deploy new spec
npx fig-teams@latest deploy

Note: The code block above assumes you build your CLI first. If you don't, your my-cli genFigSpec command won't work.

Next Steps

Customize my completion spec
Check out our Getting Started Guide guide.)

Want to associate your spec with a specific version of the CLI?
See How can my spec account for different versions of a CLI

Questions? Problems?