Skip to main content

Code Mode CLI

Use Code Mode from the command line for code generation and editing.

Commands

Generate Code

praisonai-ts tools run code-mode \
  --action generate \
  --content "Create a REST API with Express" \
  --language typescript

Edit Code

praisonai-ts tools run code-mode \
  --action edit \
  --file ./src/utils.ts \
  --content "Add error handling"

Explain Code

praisonai-ts tools run code-mode \
  --action explain \
  --file ./src/complex.ts

Review Code

praisonai-ts tools run code-mode \
  --action review \
  --file ./src/api.ts

Options

OptionTypeDefaultDescription
--actionstringgenerateAction: generate, edit, explain, review
--contentstring-Description or instructions
--filestring-Target file path
--languagestringtypescriptProgramming language
--formatbooleantrueFormat output
--outputstring-Output file path

Examples

Generate Python Script

praisonai-ts tools run code-mode \
  --action generate \
  --language python \
  --content "Web scraper for news articles" \
  --output scraper.py

Refactor File

praisonai-ts tools run code-mode \
  --action edit \
  --file ./legacy.js \
  --content "Convert to modern ES6+ syntax"

Environment Variables

VariableRequiredDescription
OPENAI_API_KEYYesFor code generation