Gemini CLI Tutorial #7 - Custom Commands
TL;DR
This tutorial demonstrates how to extend Gemini CLI by creating custom slash commands stored as TOML files in `.gemini/commands/`, enabling complex automated workflows like UI component generation with integrated testing, git branching, and preview rendering through structured multi-step prompts.
📁 Command Setup & File Structure 2 insights
Create .gemini/commands directory
Store custom command files in `.gemini/commands/` within your project root, with each command defined as a separate TOML file.
Filename determines command name
The TOML filename becomes the slash command (e.g., `component.toml` creates `/component`), requiring a CLI restart to register new commands.
⚙️ Command Configuration & Arguments 2 insights
Required TOML structure
Each file requires a `description` field (shown in CLI autocomplete) and a `prompt` field containing the multi-line instructions sent to the model.
Accessing user input
The `{{args}}` placeholder captures text entered after the command name, enabling dynamic prompts based on user specifications.
🔄 Advanced Workflow Automation 2 insights
Multi-step automated workflows
Commands can chain shell commands, manage git workflows, generate code, create test files, and render previews in a single execution.
Context-aware execution
The example validates clean git state before proceeding, derives kebab-case branch names from descriptions, and only renders components after all tests pass.
▶️ Execution & Validation 2 insights
Autocomplete integration
Custom commands appear in CLI suggestions with descriptions when typing `/`, and support arrow-key history navigation for quick reuse.
Sandbox approval workflow
Each shell command requires user approval (with 'allow always' option), and the model provides a summary of completed actions at the end.
Bottom Line
Create reusable automation workflows by storing detailed prompt templates as TOML files in `.gemini/commands/`, using `{{args}}` for dynamic input to chain shell commands, git operations, and code generation into single slash commands.
More from The Net Ninja
View all
Gemini CLI Tutorial #9 - MCP Servers & Extensions
This tutorial explains how to extend Gemini CLI beyond local codebase interaction using MCP (Model Context Protocol) servers to connect with external APIs like Firebase, and demonstrates how to install Gemini CLI extensions that bundle MCP servers with custom commands and context files.
new p5.js 2 functions: textWeight, textContours, textModel
Dan Schiffman outlines The Coding Train's return to regular content, detailing a sustainable workflow of converting live streams into edited tutorials, dual-path teaching strategies for p5.js 2.0 features like async/await and variable fonts, and a 2026 roadmap involving a studio move to enable physical computing.
More in Programming
View all
Notion Workers – Full Tutorial 2026
Notion Workers enable custom automations and external data integrations through code, but this tutorial demonstrates how AI tools like Claude Code and Codex allow non-developers to build and deploy three functional workers without traditional programming knowledge.
Claude Code Crash Course For Developers
This crash course introduces Claude Code as Anthropic's agentic coding tool that runs locally in your terminal or VS Code, covering installation, pricing tiers, model selection strategies, and a developer-focused workflow emphasizing diff review and context management over simple prompting.