Skip to main content

Sub Command

Feature Overview: Sub Command is iFlow CLI's command extension system, allowing you to install and manage specialized slash commands from the online marketplace.
Learning Time: 10-15 minutes
Prerequisites: iFlow CLI installed, authentication completed, understanding of basic slash command usage

What is Sub Command

Sub Command is the command marketplace system in iFlow CLI, allowing you to install specialized slash commands from the online marketplace to extend CLI functionality. Similar to an app store, you can browse, install, and manage various feature-rich custom commands.

Core Features

FeatureDescriptionAdvantage
Marketplace DistributionGet verified commands from online marketplaceRich feature selection
Plug-and-PlayImmediately usable after installation, no additional configurationSimplified usage flow
Scope ManagementSupport project-level and global-level command installationFlexible permission control
Version TrackingEach command has clear version informationEnsures functionality stability
Community-DrivenSupports community contributions and third-party developmentContinuous feature expansion

How It Works

Command Marketplace Architecture

Online Marketplace → Local Installation → CLI Integration → Slash Commands
↓ ↓ ↓ ↓
[Command Library] → [TOML Config] → [Command Parsing] → [Function Execution]

Scope Hierarchy

  • Global Scope: Installed to ~/.iflow/commands/, available to all projects
  • Project Scope: Installed to {project}/.iflow/commands/, only available to current project
  • Priority Rules: Project-level commands take precedence over global-level commands

Command Marketplace Management

Installing Commands from Open Marketplace

  • Visit Command Open Marketplace

  • Select search type as Commands

  • Choose your desired command

  • Click install button and copy the corresponding command

  • Install in your terminal

Browse Online Marketplace in CLI

CommandFunctionDescription
/commands onlineEnter interactive marketplaceBrowse, search, and install commands
/commands get <name or id>View command detailsGet detailed information about specific commands

Marketplace Navigation Operations

Interactive Browsing Shortcuts

OperationShortcutDescription
Browse downj or Move to next command
Browse upk or Move to previous command
View detailsl or EnterView detailed command information
Install commandiInstall currently selected command
Search filter/Search by name or category
Exit browseqExit marketplace browse mode
Refresh listrReload command list
# Enter interactive command marketplace
/commands online

# Operation examples during browsing
# 1. Use j/k or arrow keys to browse command list
# 2. Press Enter to view details of interesting commands
# 3. Press i key to directly install commands
# 4. Press / key to search for commands with specific functionality

View Command Details

# View detailed information about a specific command
/commands get 123

# Example output:
# 📋 Command Details
#
# 🆔 ID: 123
# 📝 Name: code-reviewer
# 📄 Description: Professional code review tool supporting multi-language code quality detection
# 📁 Category: Development
# 🤖 Model: claude-3-5-sonnet-20241022
# 🏷️ Tags: code-review, quality, best-practices
# 👤 Author: iflow-community
# 📊 Version: 2
# 👁️ Visibility: public
# 📋 Status: published
#
# 📖 Detail Context:
# This is a professional code review assistant that can:
# - Detect code quality issues
# - Provide best practice suggestions
# - Support multiple programming languages
# - Generate detailed review reports
#
# 💡 To add this command to your CLI, use: /commands add 123

Command Installation Guide

# Basic syntax
iflow commands add <name or id> [--scope project|global]

# Install to project (default)
iflow commands add 123
iflow commands add 123 --scope project

# Install to global
iflow commands add commit --scope global

# Actual examples
iflow commands add 456 --scope project # Code review tool
iflow commands add docs --scope global # General documentation generation tool

# View more details
iflow commands -h

View Installed Commands

# List all installed commands
/commands list
/commands show # Alias
/commands local # Alias

# Example output:
# Installed commands:
#
# 🌍 Global Commands (2):
# /code-reviewer - Professional code review tool supporting multi-language code quality detection
# 📁 /Users/username/.iflow/commands/code-reviewer.toml
#
# /doc-generator - Automatic documentation generation tool
# 📁 /Users/username/.iflow/commands/doc-generator.toml
#
# 📂 Project Commands (1):
# /project-analyzer - Project structure analysis tool
# 📁 /path/to/project/.iflow/commands/project-analyzer.toml
#
# 💡 Tips:
# • Use /commands online to browse online marketplace
# • Use /commands add <id> to install new commands
# • Use /commands remove <name> to remove commands
# • Use /commands get <id> to view command details

Remove Commands

# Remove project-level command (default)
/commands remove <command-name>
/commands remove code-reviewer

# Remove global command
/commands remove code-reviewer --scope global

# Alias commands
/commands rm <command-name>
/commands delete <command-name>

# Successful removal example:
# ✅ Successfully removed command 'code-reviewer' from project scope
# Location: /path/to/project/.iflow/commands/code-reviewer.toml
#
# ⚠️ Please restart the CLI to see changes take effect.

Command Categories and Recommendations

Development Tools

Command NameIDFunction DescriptionUse Cases
refactor79Refactor code while maintaining functionality and improving structure, readability, and maintainabilityCode optimization and structural adjustments
implement80Intelligently implement features perfectly adapted to project architectureNew feature development
test81Intelligently run tests based on current context and help fix failuresTest automation
scaffold94Generate complete feature from schemaRapid prototyping
fix-imports87Fix broken imports after refactoringPost-refactoring maintenance
fix-todos88Intelligently implement TODO fixesTask management
format89Auto-detect and apply project formatterCode formatting

Code Quality

Command NameIDFunction DescriptionUse Cases
review93Multi-agent analysis (security, performance, quality, architecture)Code review
make-it-pretty90Improve readability without changing functionalityCode beautification
remove-comments92Clean obvious comments, preserve valuable documentationCode cleanup
predict-issues91Proactive issue detection with timeline estimatesRisk prediction

Documentation Tools

Command NameIDFunction DescriptionUse Cases
docs84Intelligent documentation management and updatesProject documentation maintenance
contributing82Complete analysis of project contribution readinessOpen source projects
explain-like-senior85Senior-level code explanation and context analysisCode learning

Security Analysis

Command NameIDFunction DescriptionUse Cases
security-scan95Extended thinking vulnerability analysis and fix trackingSecurity checks

Utility Tools

Command NameIDFunction DescriptionUse Cases
commit78Analyze changes and create meaningful commit messagesGit workflow
cleanproject77Clean development artifacts while preserving working codeProject maintenance
create-todos83Add contextual TODO comments based on analysisTask management
find-todos86Locate and organize development tasksTask tracking
session-end96Summarize and save session contextSession management

Command Configuration Files

TOML File Structure

Installed commands generate local TOML configuration files:

# Command: code-reviewer
# Description: Professional code review tool supporting multi-language code quality detection
# Category: Development
# Version: 2
# Author: iflow-community

description = "Professional code review tool supporting multi-language code quality detection"

prompt = """
You are a professional code review expert. Please analyze the code provided by the user and evaluate from the following aspects:

1. Code quality and readability
2. Security issue detection
3. Performance optimization suggestions
4. Best practice compliance
5. Potential bugs or logical errors

Please provide specific improvement suggestions and example code.
"""

Markdown File Structure

In addition to TOML format, iFlow CLI also supports Markdown format configuration files.

# Create command directory
mkdir -p ~/.iflow/commands

# Create Markdown format command file
echo "Review this code for security vulnerabilities:" > ~/.iflow/commands/security-review.md

You can also add descriptions, for example:

---
description: Create a git commit
---

## Context

- Current git status: !`git status`
- Current git diff (staged and unstaged changes): !`git diff HEAD`
- Current branch: !`git branch --show-current`
- Recent commits: !`git log --oneline -10`

## Your task

Based on the above changes, create a single git commit.

Configuration File Locations

ScopeConfiguration PathDescription
Global~/.iflow/commands/Accessible to all projects
Project{project}/.iflow/commands/Only accessible to current project

Troubleshooting

Common Issues and Solutions

IssuePossible CauseSolution
Command installation failureAPI key not set or expiredRe-authenticate
Command unavailableCLI not restarted to load new configurationRestart iFlow CLI
Permission errorInsufficient directory permissionsCheck file system permissions
Network connection failureCannot access command marketplace APICheck network connection and firewall settings
Command conflictSame-named commands in different scopesUse --scope to specify explicitly

Diagnostic Steps

  1. Connection Check

    # Test API connection
    /commands online

    # Check authentication status
    /auth status
  2. Configuration Verification

    # View local command list
    /commands list

    # Check configuration file
    cat ~/.iflow/commands/command-name.toml
  3. Permission Verification

    # Check directory permissions
    ls -la ~/.iflow/commands/
    ls -la ./.iflow/commands/
  4. Log Check

    # View detailed logs
    /log

    # View error information
    /debug

Cleanup and Reset

# Clean project-level commands
rm -rf ./.iflow/commands/

# Clean global commands (use with caution)
rm -rf ~/.iflow/commands/

# Reinitialize command configuration
iflow commands init

Security Considerations

Security Recommendations for Third-party Commands

Verify Command Sources:

  • ⚠️ Only install commands from trusted authors
  • ⚠️ Check command ratings and community feedback
  • ⚠️ Avoid installing commands with overly broad permissions

Command Permission Control:

  • ✅ Prefer project scope installation
  • ✅ Regularly audit installed commands
  • ✅ Keep commands updated to latest versions
  • ✅ Remove unused commands

Developing Custom Commands

Complete TOML Configuration Specification

Basic Configuration Structure

# Command description (required)
description = "Brief command description"

# Command prompt (required)
prompt = """
Complete prompt content sent to AI model
Supports multi-line text and special placeholders
"""

Advanced Feature Specifications

1. Parameter Injection Mechanism

Shortcut Parameter Injection: Use {{args}} placeholder

description = "Code review tool"

prompt = """
Please review the following code and provide improvement suggestions:

{{args}}

Focus on: code quality, security, performance optimization.
"""

Default Parameter Handling: If not using {{args}}, system automatically appends user input to prompt

description = "Documentation generator"

prompt = """
Generate professional documentation based on provided content.
"""
# User input "/docs User Manual" becomes:
# "Generate professional documentation based on provided content.\n\n/docs User Manual"
2. Shell Command Integration

Use !{command} syntax to execute Shell commands in prompts:

description = "Project analysis tool"

prompt = """
Current project information:

File structure:
!{find . -name "*.js" -o -name "*.ts" | head -20}

Git status:
!{git status --porcelain}

Please analyze project status and provide suggestions.
"""

Security Mechanisms:

  • Shell commands require security checks
  • Support global and session-level command whitelists
  • Dangerous commands require user confirmation
3. Prompt Processor Chain

System uses processor chain pattern to handle TOML configuration:

ProcessorTrigger ConditionFunction
ShellProcessorContains !{...}Execute Shell commands and replace output
ShorthandArgumentProcessorContains {{args}}Replace argument placeholders
DefaultArgumentProcessorDefaultAppend user input to prompt

Development Environment Setup

Directory Structure Management

# Global command directory
~/.iflow/commands/
├── my-command.toml
├── code-reviewer.toml
└── project-analyzer.toml

# Project command directory
/path/to/project/.iflow/commands/
├── deploy.toml
├── test-runner.toml
└── build-helper.toml

Path Resolution Rules

System uses the following functions to get command directories:

// Global command directory
getUserCommandsDir(): string {
return path.join(os.homedir(), '.iflow', 'commands');
}

// Project command directory
getProjectCommandsDir(projectRoot: string): string {
return path.join(projectRoot, '.iflow', 'commands');
}

File Naming Conventions

  • Basic Naming: command-name.toml
  • Hierarchical Naming: parent:child.toml → Creates nested command structure
  • Filename Cleanup: Non-alphanumeric characters converted to hyphens
  • Extended Namespace: Extended commands automatically get [extensionName] prefix

Practical Development Examples

Example 1: Simple Information Query Command

# ~/.iflow/commands/system-info.toml
description = "Display system information summary"

prompt = """
Please perform the following system checks and provide a summary:

Operating System: !{uname -a}
Disk Usage: !{df -h /}
Memory Usage: !{free -h}
Current Directory: !{pwd}

Please analyze system status and provide suggestions.
"""

Usage: /system-info

Example 2: Parameterized Code Generator

# ./iflow/commands/generate-component.toml  
description = "React component generator"

prompt = """
Please generate a React component with the following requirements:

{{args}}

Please include:
1. TypeScript interface definitions
2. Complete component implementation
3. Basic CSS styles
4. Usage examples

Follow best practices and modern React patterns.
"""

Usage: /generate-component User login form component

Example 3: Complex Project Management Tool

# ./.iflow/commands/project:status.toml
description = "Comprehensive project status analysis"

prompt = """
Comprehensive project status report:

## Repository Status
Git branch: !{git branch --show-current}
Uncommitted changes: !{git status --porcelain | wc -l}
Recent commits: !{git log --oneline -5}

## Dependency Status
Package.json exists: !{test -f package.json && echo "✅ Exists" || echo "❌ Not found"}
Node modules status: !{test -d node_modules && echo "✅ Installed" || echo "❌ Not installed"}

## Code Quality
TypeScript files: !{find . -name "*.ts" -o -name "*.tsx" | wc -l}
JavaScript files: !{find . -name "*.js" -o -name "*.jsx" | wc -l}
Test files: !{find . -name "*.test.*" -o -name "*.spec.*" | wc -l}

Please analyze project health and provide improvement suggestions.
"""

Usage: /project:status

Example 4: Dynamic Script Executor

# ~/.iflow/commands/run-with-context.toml
description = "Execute commands in project context"

prompt = """
Execute specified operations in current project environment:

Project root directory: !{pwd}
Operation content: {{args}}

Execution result:
!{{{args}}}

Please analyze execution results and provide follow-up suggestions.
"""

Usage: /run-with-context npm test

Debugging and Testing Guide

Configuration Validation

System uses Zod for TOML configuration validation:

const TomlCommandDefSchema = z.object({
prompt: z.string({
required_error: "The 'prompt' field is required.",
invalid_type_error: "The 'prompt' field must be a string.",
}),
description: z.string().optional(),
});

Common Errors and Solutions

Error TypeCauseSolution
TOML parsing errorIncorrect syntaxCheck quotes, indentation, and escape characters
Schema validation failureMissing required fieldsEnsure prompt field is included
Shell command blockedSecurity policy restrictionsAdd to command whitelist or modify security config
Command not showingIncorrect file locationCheck file path and restart CLI

Development Workflow

  1. Create TOML file

    mkdir -p ./.iflow/commands
    touch ./.iflow/commands/my-command.toml
  2. Write configuration content

    description = "Test command"
    prompt = "This is a test command"
  3. Restart CLI to load new command

    # Exit current session
    /quit
    # Restart
    iflow
  4. Test command functionality

    /my-command Test parameters
  5. View debugging information

    /log  # View system logs
    /debug # Enable debug mode