pt edit
Edit existing prompt files in your configured editor. This command provides an easy way to modify prompts with search and selection capabilities.
Synopsis
bash
pt edit [prompt-name] [options]Purpose
The edit command:
- Opens prompts in your preferred editor
- Supports interactive selection
- Allows direct file path editing
- Validates edits after saving
- Maintains prompt metadata
- Supports batch editing
Options
| Option | Short | Description |
|---|---|---|
--editor <editor> | -e | Override default editor |
--search <query> | -s | Search for prompt to edit |
--all | -a | Open all matching prompts |
--validate | -v | Validate after editing |
--help | -h | Show help information |
Usage Modes
Interactive Selection
bash
# Browse and select prompt
pt edit- Shows searchable prompt list
- Preview before selection
- Opens selected prompt in editor
Direct Edit
bash
# Edit by name or path
pt edit api-client
pt edit frontend/component.md
pt edit ~/.prompts/review.mdSearch and Edit
bash
# Find and edit matching prompt
pt edit --search "api documentation"
# Edit all matching prompts
pt edit --search "review" --allExamples
Basic Editing
bash
# Interactive selection
pt edit
# Edit specific prompt
pt edit code-review
# Edit with full path
pt edit ./prompts/templates/api.mdAdvanced Usage
bash
# Use specific editor
pt edit api-client --editor "code --wait"
# Search and edit
pt edit -s "typescript"
# Edit multiple files
pt edit -s "api" --allValidation
bash
# Validate after editing
pt edit buggy-prompt.md --validate
# Check syntax without opening
pt edit broken.md --validate --dry-runEditor Integration
VS Code
bash
# Single file
export EDITOR="code --wait"
# Multiple files
export EDITOR="code --wait --new-window"Vim/Neovim
bash
# Vim
export EDITOR="vim"
# Neovim with config
export EDITOR="nvim -u ~/.config/nvim/init.lua"Other Editors
bash
# Sublime Text
export EDITOR="subl --wait"
# Emacs
export EDITOR="emacs"
# Nano
export EDITOR="nano"Search Features
Fuzzy Search
- Partial word matching
- Case-insensitive
- Searches title, tags, and content
Search Examples
bash
# Find "review" prompts
pt edit -s rev
# Find by tag
pt edit -s "#typescript"
# Complex search
pt edit -s "api client generator"Batch Editing
Edit Multiple Files
bash
# Open all API-related prompts
pt edit -s api --all
# Edit all prompts in subdirectory
pt edit "frontend/*" --allScripted Edits
bash
# Find and replace across prompts
for prompt in $(pt list -s api); do
pt edit "$prompt"
doneValidation Features
Syntax Checking
- YAML frontmatter validation
- Template helper verification
- Variable definition checks
Validation Output
✓ Valid YAML frontmatter
✓ All variables properly defined
✓ Template helpers correct
⚠ Warning: Unused variable 'apiKey'Common Workflows
Updating Metadata
bash
# Update tags across prompts
pt edit -s "old-tag" --all
# Then: Update tags in frontmatterRefactoring Templates
bash
# Find prompts using old helper
pt edit -s "{{oldHelper" --all
# Then: Update to new helper syntaxVersion Updates
bash
# Update prompt versions
pt edit important-prompt.md
# Then: Update version in frontmatterTips and Tricks
Quick Edits
bash
# Last edited prompt
pt edit $(pt history -l 1 --format json | jq -r '.prompt.path')
# Most used prompt
pt edit $(pt review --format json | jq -r '.[0].name')Editor Productivity
bash
# Open in split view (VS Code)
export EDITOR="code --wait --diff"
# Open at specific line
export EDITOR="vim +10" # Line 10Safety Measures
bash
# Backup before editing
cp prompt.md prompt.md.bak && pt edit prompt.md
# Git tracking
git add prompts/ && pt edit my-prompt.mdTroubleshooting
Editor Not Opening
bash
# Debug editor detection
pt edit --debug
# Check environment
echo $EDITOR
echo $VISUAL
# Force specific editor
pt edit -e nanoFile Not Found
bash
# List available prompts
pt list
# Check prompt directories
cat .pt-config.json | jq '.promptDirs'Permission Issues
bash
# Check file permissions
ls -la prompts/
# Fix permissions
chmod 644 prompts/*.mdBest Practices
- Version Control: Commit before major edits
- Validation: Always validate after complex changes
- Backups: Keep backups of important prompts
- Comments: Document changes in prompts
- Testing: Test edited prompts immediately
Related Commands
pt- Test edited promptspt add- Create new promptspt history- See prompt usagept run- Execute edited prompts
Configuration
Edit behavior can be customized:
json
{
"editor": "code --wait",
"editOptions": {
"validate": true,
"backup": true,
"openInNewWindow": false
}
}Next Steps
After editing:
- Test changes with
pt - Validate syntax if needed
- Commit changes to version control
- Share updates with team
