Skip to main content

Slash Commands

Slash commands let you trigger actions by typing /command in the capture window. CommandLane includes built-in commands and supports custom user scripts.

Using Slash Commands

Type / followed by a command name in the capture window:

/find project:finance
/resume 10
/snippet list

Press Enter to execute the command.

Built-in Commands

/resume

Resume a previous chat conversation.

/resume           # List 10 most recent conversations
/resume 5 # List 5 most recent conversations
/resume 50 # List up to 50 conversations

Returns a list of conversations with:

  • Conversation ID
  • Title
  • Creation date
  • Message count
  • AI provider and model used

/snippet

Manage text expansions. See Text Expansions for details.

/snippet list                              # List all expansions
/snippet add :sig "Best regards, Matt" # Add snippet
/snippet remove :sig # Remove snippet
/snippet help # Show help

Custom Commands

Create your own slash commands by adding scripts to ~/.cmdlane/scripts/.

Supported Languages

ExtensionInterpreter
.pyPython (same as CommandLane)
.ps1PowerShell
.shBash
.jsNode.js
.bat, .cmdWindows CMD

Creating a Custom Command

  1. Create the scripts directory:

    mkdir ~/.cmdlane/scripts
  2. Create a script file:

    # ~/.cmdlane/scripts/weekly-review.py
  3. The filename becomes the command name:

    • weekly-review.py/weekly-review
    • project-switch.sh/project-switch

Script Structure

#!/usr/bin/env python3
# @description: Generate a weekly review summary

import sys

# Arguments passed after command name
# /weekly-review 14 → sys.argv[1] = "14"
days = int(sys.argv[1]) if len(sys.argv) > 1 else 7

# Your logic here
print(f"Reviewing last {days} days...")

# Output is shown to user

The # @description: comment provides help text shown when listing commands.

Example Custom Commands

Weekly Review

Generate a summary of recent captures:

#!/usr/bin/env python3
# @description: Generate weekly review from recent captures

import sys
import json
import sqlite3
from pathlib import Path
from datetime import datetime, timedelta

days = int(sys.argv[1]) if len(sys.argv) > 1 else 7
cutoff = datetime.now() - timedelta(days=days)

db_path = Path.home() / ".cmdlane" / "pkb_data.db"
conn = sqlite3.connect(db_path)

# Count by type
cursor = conn.execute("""
SELECT entry_type, COUNT(*)
FROM entries
WHERE created_at > ?
GROUP BY entry_type
""", (cutoff.isoformat(),))

results = dict(cursor.fetchall())
conn.close()

print(f"## Weekly Review ({days} days)")
print(f"- Tasks: {results.get('task', 0)}")
print(f"- Notes: {results.get('note', 0)}")
print(f"- Decisions: {results.get('decision', 0)}")

Quick Project Switch

Switch context to a different project:

#!/usr/bin/env python3
# @description: Set active project context

import sys
import json
from pathlib import Path

if len(sys.argv) < 2:
print("Usage: /project <project-name>")
sys.exit(1)

project = sys.argv[1]
config_path = Path.home() / ".cmdlane" / "context.json"

context = {"active_project": project}
config_path.write_text(json.dumps(context, indent=2))

print(f"✓ Switched to project: {project}")

Open Dashboard

Launch a specific dashboard page:

# ~/.cmdlane/scripts/dashboard.ps1
# @description: Open dashboard to specific page

param([string]$page = "overview")

$uri = "commandlane://dashboard/$page"
Start-Process $uri
Write-Host "Opening dashboard: $page"

Daily Standup Template

Insert a standup template:

#!/usr/bin/env python3
# @description: Generate daily standup template

from datetime import datetime

date = datetime.now().strftime("%Y-%m-%d")
template = f"""## Standup - {date}

### Yesterday
-

### Today
-

### Blockers
- None
"""

print(template)

Search Shortcut

Quick search with predefined filters:

#!/usr/bin/env python3
# @description: Search recent tasks

import sys
import subprocess

query = " ".join(sys.argv[1:]) if len(sys.argv) > 1 else ""
cmd = ["pkb", "find", "--type", "task", "--since", "7d"]

if query:
cmd.extend(["--text", query])

result = subprocess.run(cmd, capture_output=True, text=True)
print(result.stdout)

Command Result Handling

Scripts can output:

  • Plain text - Displayed to user
  • Markdown - Rendered with formatting
  • JSON - Parsed and displayed appropriately

Exit Codes

  • 0 - Success
  • Non-zero - Error (message shown to user)
#!/usr/bin/env python3
import sys

if some_error_condition:
print("Error: Something went wrong", file=sys.stderr)
sys.exit(1)

print("Success!")
sys.exit(0)

Listing Available Commands

View all available commands (built-in and custom):

/help

Or from the CLI:

pkb commands list

Best Practices

Keep Commands Fast

Commands should complete quickly (under 2 seconds). For longer operations:

  • Show progress indicators
  • Run heavy work asynchronously
  • Consider using a hook instead

Handle Missing Arguments

#!/usr/bin/env python3
import sys

if len(sys.argv) < 2:
print("Usage: /mycommand <required-arg>")
print("Example: /mycommand value")
sys.exit(1)

arg = sys.argv[1]
# Continue with logic

Provide Helpful Descriptions

Always include a @description comment:

#!/usr/bin/env python3
# @description: Brief description shown in /help

# Script logic...

Error Messages

Write clear, actionable error messages:

# Bad
print("Error")

# Good
print("Error: Could not find project 'foo'. Run /project list to see available projects.")

Debugging Commands

Test Manually

Run your script directly:

python ~/.cmdlane/scripts/weekly-review.py 14

Check Script Permissions

On Unix-like systems, ensure scripts are executable:

chmod +x ~/.cmdlane/scripts/weekly-review.py

View Command Output

Command output appears in the capture window. For debugging, add verbose output:

import sys
print("Debug: starting command", file=sys.stderr)
# Your logic
print("Debug: finished", file=sys.stderr)