This document provides comprehensive documentation for the Inference Gateway CLI shortcuts system, including built-in shortcuts, AI-powered snippets, and custom shortcut creation.
- Overview
- Built-in Shortcuts
- Git Shortcuts
- SCM Shortcuts
- AI-Powered Snippets
- User-Defined Shortcuts
- Advanced Usage
- Troubleshooting
The CLI provides an extensible shortcuts system that allows you to quickly execute common commands
with /shortcut-name syntax during chat sessions.
Key Features:
- Quick command execution with
/prefix - Built-in shortcuts for common operations
- Git and GitHub integration
- AI-powered snippets for intelligent automation
- Fully customizable with YAML configuration
- Support for command chaining and complex workflows
These shortcuts are available out of the box:
/clear- Clear conversation history/exit- Exit the chat session/help [shortcut]- Show available shortcuts or specific shortcut help/switch- Switch to a different model/theme- Switch chat interface theme or list available themes/config <show|get|set|reload> [key] [value]- Manage configuration settings/compact- Immediately compact conversation to reduce token usage/export [format]- Export conversation to markdown/init- Set input with project analysis prompt for AGENTS.md generation
The /init shortcut populates the input field with a configurable prompt for generating an AGENTS.md
file. This allows you to:
- Type
/initto populate the input with the project analysis prompt - Review and optionally modify the prompt before sending
- Press Enter to send the prompt and watch the agent analyze your project interactively
The prompt is configurable in your config file under init.prompt. The default prompt instructs the agent to:
- Analyze your project structure, build tools, and configuration files
- Create comprehensive documentation for AI agents
- Generate an AGENTS.md file with project overview, commands, and conventions
When you run infer init, a .infer/shortcuts/git.yaml file is created with common git operations:
/git status- Show working tree status/git pull- Pull changes from remote repository/git push- Push commits to remote repository/git log- Show commit logs (last 5 commits)/git commit- Generate AI commit message from staged changes
The /git commit shortcut uses the snippet feature to generate conventional commit messages:
- Analyzes your staged changes (
git diff --cached) - Sends the diff to the LLM with a prompt to generate a conventional commit message
- Automatically commits with the AI-generated message
Example Usage:
# Stage your changes
git add .
# Generate commit message and commit
/git commitThe AI will generate a commit message following the conventional commit format (e.g.,
feat: Add user authentication, fix: Resolve memory leak).
Requirements:
- Run
infer initto create the shortcuts file - Stage changes with
git addbefore using/git commit - The shortcut uses
jqto format JSON output
The SCM (Source Control Management) shortcuts provide seamless integration with GitHub and git workflows.
When you run infer init, a .infer/shortcuts/scm.yaml file is created with the following shortcuts:
/scm issues- List all GitHub issues for the repository/scm issue <number>- Show details for a specific GitHub issue with comments/scm pr-create [optional context]- Generate AI-powered PR plan with branch name, commit, and description
The /scm pr-create shortcut uses the snippet feature to analyze your changes and generate a complete PR plan:
- Analyzes staged or unstaged changes (
git diff) - Sends the diff to the LLM with context about the current and base branches
- Optionally accepts additional context to help the AI understand the purpose of the changes
- Generates a comprehensive PR plan including:
- Suggested branch name (following conventional format:
feat/,fix/, etc.) - Conventional commit message
- PR title and description
- Suggested branch name (following conventional format:
This provides a deterministic way to fetch GitHub data and AI assistance for PR planning.
Example Usage:
# List all open issues
/scm issues
# View details for issue #123 including comments
/scm issue 123
# Generate PR plan (basic)
/scm pr-create
# Generate PR plan with additional context
/scm pr-create This fixes the timing issue where conversations were loading too slowly
# Generate PR plan with quoted context (for complex explanations)
/scm pr-create "This implements user-requested feature for dark mode support"Requirements:
- GitHub CLI (
gh) must be installed and authenticated - Run
infer initto create the shortcuts file - The commands work in any git repository with a GitHub remote
You can customize these shortcuts by editing .infer/shortcuts/scm.yaml:
shortcuts:
- name: scm
description: "Source control management operations"
command: gh
subcommands:
- name: issues
description: "List all GitHub issues for the repository"
args:
- issue
- list
- --json
- number,title,state,author,labels,createdAt,updatedAt
- --limit
- "20"Use Cases:
- Quickly get context on what issues need to be worked on
- Fetch issue details and comments before implementing a fix
- Let the LLM analyze issue discussions to understand requirements
- Customize the shortcuts to add filters, change limits, or modify output format
Shortcuts can use the snippet feature to integrate LLM-powered workflows directly into YAML configuration. This enables complex AI-assisted tasks without writing Go code.
- Command Execution: The shortcut runs a command that outputs JSON data
- Prompt Generation: A prompt template is filled with the JSON data and sent to the LLM
- Template Filling: The final template is filled with both JSON data and the LLM response
- Result Display: The filled template is shown to the user or executed
shortcuts:
- name: example-snippet
description: "Example AI-powered shortcut"
command: bash
args:
- -c
- |
# Command must output JSON
jq -n --arg data "Hello" '{message: $data}'
snippet:
prompt: |
You are given this data: {message}
Generate a response based on it.
template: |
## AI Response
{llm}{fieldname}- Replaced with values from the command's JSON output{llm}- Replaced with the LLM's response to the prompt
The /git commit shortcut demonstrates the snippet feature:
shortcuts:
- name: git
description: "Common git operations"
command: git
subcommands:
- name: commit
description: "Generate AI commit message from staged changes"
command: bash
args:
- -c
- |
if ! git diff --cached --quiet 2>/dev/null; then
diff=$(git diff --cached)
jq -n --arg diff "$diff" '{diff: $diff}'
else
echo '{"error": "No staged changes found."}'
exit 1
fi
snippet:
prompt: |
Generate a conventional commit message.
Changes:
```diff
{diff}
```
Format: "type: Description"
- Type: feat, fix, docs, refactor, etc.
- Description: "Capital first letter, under 50 chars"
Output ONLY the commit message.
template: "!git commit -m \"{llm}\""How This Works:
- Command runs
git diff --cachedand outputs JSON:{"diff": "..."} - Prompt template receives the diff via
{diff}placeholder - LLM generates commit message (e.g.,
feat: Add user authentication) - Template receives LLM response via
{llm}placeholder - Final command executed:
git commit -m "feat: Add user authentication"
If the template starts with !, the result is executed as a shell command:
template: "!git commit -m \"{llm}\"" # Executes the command
template: "{llm}" # Just displays the result- Generate commit messages from diffs
- Create PR descriptions from changes
- Analyze test output and suggest fixes
- Generate code documentation from source
- Transform data formats with AI assistance
- Automate complex workflows with AI decision-making
You can create custom shortcuts by adding YAML configuration files in the .infer/shortcuts/ directory.
Create files named custom-*.yaml (e.g., custom-1.yaml, custom-dev.yaml) in .infer/shortcuts/:
shortcuts:
- name: tests
description: "Run all tests in the project"
command: go
args:
- test
- ./...
working_dir: . # Optional: set working directory
- name: build
description: "Build the project"
command: go
args:
- build
- -o
- infer
- .
- name: lint
description: "Run linter on the codebase"
command: golangci-lint
args:
- run- name (required): The shortcut name (used as
/name) - description (required): Human-readable description shown in
/help - command (required): The executable command to run
- args (optional): Array of arguments to pass to the command
- working_dir (optional): Working directory for the command (defaults to current)
- snippet (optional): AI-powered snippet configuration with
promptandtemplatefields
With the configuration above, you can use:
/tests- Runsgo test ./.../build- Runsgo build -o infer ./lint- Runsgolangci-lint run
You can also pass additional arguments:
/tests -v- Runsgo test ./... -v/build --race- Runsgo build -o infer . --race
Here are some useful shortcuts you might want to add:
Development Shortcuts (custom-dev.yaml):
shortcuts:
- name: fmt
description: "Format all Go code"
command: go
args:
- fmt
- ./...
- name: "mod tidy"
description: "Tidy up go modules"
command: go
args:
- mod
- tidy
- name: version
description: "Show current version"
command: git
args:
- describe
- --tags
- --always
- --dirtyDocker Shortcuts (custom-docker.yaml):
shortcuts:
- name: "docker build"
description: "Build Docker image"
command: docker
args:
- build
- -t
- myapp
- .
- name: "docker run"
description: "Run Docker container"
command: docker
args:
- run
- -p
- "8080:8080"
- myappProject-Specific Shortcuts (custom-project.yaml):
shortcuts:
- name: migrate
description: "Run database migrations"
command: ./scripts/migrate.sh
working_dir: .
- name: seed
description: "Seed database with test data"
command: go
args:
- run
- cmd/seed/main.go- File Organization: Use descriptive names for your config files (e.g.,
custom-dev.yaml,custom-docker.yaml) - Command Discovery: Use
/helpto see all available shortcuts including your custom ones - Error Handling: If a custom shortcut fails to load, it will be skipped with a warning
- Reloading: Restart the chat session to reload custom shortcuts after making changes
- Security: Be careful with custom shortcuts as they execute system commands
- Check YAML syntax: Ensure your configuration file is valid YAML
- Check file naming: Files must be named
custom-*.yaml(notshortcut-*.yamlor other patterns) - Check location: Files must be in
.infer/shortcuts/directory - Restart chat: Restart the chat session to reload shortcuts
- Check PATH: Ensure the command is available in your system PATH
- Use absolute paths: For custom scripts, use absolute paths or
./script.sh - Test manually: Try running the command directly in your terminal first
- Check file permissions: Ensure script files are executable (
chmod +x script.sh) - Check directory permissions: Ensure the working directory is accessible
- Check user permissions: Ensure you have permission to run the command
- Use a validator: Use an online YAML validator or
yamllintto check syntax - Check indentation: YAML is sensitive to indentation (use spaces, not tabs)
- Check quotes: Use quotes for strings with special characters
- Check arrays: Ensure arrays are properly formatted with
-prefix
- Check JSON output: Ensure your command outputs valid JSON
- Check placeholders: Ensure placeholders match JSON fields exactly
- Check template syntax: Ensure template uses correct placeholder syntax
{field} - Test command separately: Run the command manually to verify JSON output