Skip to content

Using Slash Commands

Slash Commands enable you to quickly add context to the chat buffer. They are comprised of values present in the strategies.chat.slash_commands table alongside the prompt_library table where individual prompts have opts.is_slash_cmd = true.

/buffer

The buffer slash command enables you to add the contents of any open buffers in Neovim to the chat buffer. The command has native, Telescope, mini.pick, fzf.lua and snacks.nvim providers available. Also, multiple buffers can be selected and added to the chat buffer as per the video above.

/fetch

TIP

To better understand a Neovim plugin, send its config.lua to your LLM via the fetch command alongside a prompt

The fetch slash command allows you to add the contents of a URL to the chat buffer. By default, the plugin uses the awesome and powerful jina.ai to parse the page's content and convert it into plain text. For convenience, the slash command will cache the output to disk and prompt the user if they wish to restore from the cache, should they look to fetch the same URL.

/file

The file slash command allows you to add the contents of a file in the current working directory to the chat buffer. The command has native, Telescope, mini.pick, fzf.lua and snacks.nvim providers available. Also, multiple files can be selected and added to the chat buffer.

/help

The help slash command allows you to add content from a vim help file (:h helpfile), to the chat buffer, by searching for help tags. Currently this is only available for Telescope, mini.pick, fzf_lua and snacks.nvim providers. By default, the slash command will prompt you to trim a help file that is over 1,000 lines in length.

/now

The now slash command simply inserts the current datetime stamp into the chat buffer.

/symbols

NOTE

If a filetype isn't supported please consider making a PR to add the corresponding Tree-sitter queries from aerial.nvim

The symbols slash command uses Tree-sitter to create a symbolic outline of a file to share with the LLM. This can be a useful way to minimize token consumption whilst sharing the basic outline of a file. The plugin utilizes the amazing work from aerial.nvim by using their Tree-sitter symbol queries as the basis. The list of filetypes that the plugin currently supports can be found here.

The command has native, Telescope, mini.pick, fzf.lua and snacks.nvim providers available. Also, multiple symbols can be selected and added to the chat buffer.

/terminal

The terminal slash command shares the latest output from the last terminal buffer with the chat buffer. This can be useful for sharing the outputs of test runs with your LLM.

/workspace

The workspace slash command allows users to share defined groups of files and/or symbols with an LLM, alongside some pre-written context. The slash command uses a codecompanion-workspace.json file, stored in the current working directory, to house this context. It is, in essence, a context management system for your repository.

Whilst LLMs are incredibly powerful, they have no knowledge of the architectural decisions yourself or your team have made on a project. They have no context as to why you've selected the dependencies that you have. And, they can't see how your codebase has evolved over time.

Please see the Creating Workspaces guide to learn how to build your own.

Released under the MIT License.