AI Code Editor Examples
10 real-world examples of PraisonAI as an AI code editor – editing files, running tests, and fixing bugs
Overview
PraisonAI functions as a real AI code editor that can:
- Edit files on disk
- Run terminal commands (pytest, ruff, etc.)
- Observe failures and fix them
- Converge to green tests
This guide covers 10 real-world scenarios demonstrating these capabilities.
CLI Contract (January 2026)
| Command | Description | Key Flags |
|---|---|---|
praisonai chat | Terminal-native REPL | -m, -w, -f, -c, -s |
praisonai code | Terminal-native code assistant | -m, -w, -f, -c, -s |
praisonai tui | Full TUI interface | -w, -s, -m |
praisonai ui chat | Browser-based chat | --port, --host |
praisonai ui code | Browser-based code | --port, --host |
Key Flags
| Flag | Description |
|---|---|
-m, --model | LLM model to use (default: provider-aware — falls back to gpt-4o-mini when no credential is set; see Models → Provider Auto-Detection) |
-w, --workspace | Working directory for file operations |
-f, --file | Attach file(s) to prompt |
-c, --continue | Continue last session (re-roots tools into the resumed session’s directory) |
-s, --session | Resume specific session ID (re-roots tools into the resumed session’s directory) |
--no-acp | Disable ACP tools |
--no-lsp | Disable LSP tools |
Auto-Approval for Automation
Set PRAISON_APPROVAL_MODE=auto to enable non-interactive tool execution. This is the opt-out from the safe default: praisonai code --safe uses prompt, so only set auto for scripted, non-interactive runs where per-call prompts aren’t an option.
PRAISON_APPROVAL_MODE=auto praisonai code -w . "Fix the bug"Windows Automation
Windows requires additional configuration for non-interactive runs. The --no-acp flag is required to prevent hangs, and UTF-8 encoding must be set for subprocess operations.
graph LR
subgraph "praisonai code on Windows"
A[👤 User Prompt] --> B{🪟 Windows?}
B -->|Yes| C[➕ add --no-acp<br/>set PYTHONIOENCODING=utf-8]
B -->|No| D[Run as normal]
C --> E[🤖 Agent edits files<br/>runs tests, fixes bugs]
D --> E
E --> F[✅ Green tests]
end
classDef input fill:#6366F1,stroke:#7C90A0,color:#fff
classDef branch fill:#F59E0B,stroke:#7C90A0,color:#fff
classDef agent fill:#189AB4,stroke:#7C90A0,color:#fff
classDef done fill:#10B981,stroke:#7C90A0,color:#fff
class A input
class B,C branch
class D,E agent
class F doneWindows PowerShell Example
# Windows PowerShell — run praisonai code non-interactively
$env:PRAISON_APPROVAL_MODE = "auto"
$env:PYTHONIOENCODING = "utf-8"
$env:OPENAI_API_KEY = "${OPENAI_API_KEY}"
praisonai code -w . --no-acp "Implement celsius_to_fahrenheit in src/converter.py and run pytest until it passes."Windows cmd.exe Example
:: Windows cmd.exe
set PRAISON_APPROVAL_MODE=auto
set PYTHONIOENCODING=utf-8
set OPENAI_API_KEY=${OPENAI_API_KEY}
praisonai code -w . --no-acp "Implement celsius_to_fahrenheit in src/converter.py and run pytest until it passes."Prerequisites
pip install praisonai praisonaiagents
export OPENAI_API_KEY=your-key-hereAI Code Editor Scenarios
1. Implement Code from Specification
Implement a function and run tests until they pass.
praisonai chat -w . -m gpt-4o-mini "Implement the celsius_to_fahrenheit function in src/converter.py. Formula: F = C * 9/5 + 32. Run pytest to verify."What happens:
- Agent reads the existing file
- Implements the function with the formula
- Runs
pytestto verify - If tests fail, fixes and reruns
2. Fix Division by Zero Bug
Fix a bug that causes test failures.
praisonai chat -w . -m gpt-4o-mini "Fix the divide method in calculator.py to raise ValueError('Cannot divide by zero') when b is 0. Run pytest to verify."What happens:
- Agent reads the buggy code
- Adds the zero-check with proper error
- Runs tests to confirm the fix
- Iterates until tests pass
3. Implement Missing Function
Implement a function that’s currently a stub.
praisonai chat -w . -m gpt-4o-mini "Implement the mode function in stats.py. Mode returns the most frequent value. Run pytest -k mode to verify."What happens:
- Agent reads the stub function
- Implements the logic using Counter or similar
- Runs targeted tests
- Fixes any edge cases
4. Fix Empty List Handling
Add proper error handling for edge cases.
praisonai chat -w . -m gpt-4o-mini "Fix mean() in stats.py to raise ValueError('Cannot calculate mean of empty list') for empty input. Run pytest -k mean."What happens:
- Agent adds input validation
- Raises appropriate error
- Verifies with tests
5. Add CLI Command
Extend a CLI with a new command.
praisonai chat -w . -m gpt-4o-mini "Add a 'version' command to cli.py that prints __version__. Test with: python -m myapp.cli version"What happens:
- Agent reads the CLI code
- Adds the version subcommand
- Runs the command to verify output
6. Fix Lint Errors
Clean up code style issues.
praisonai chat -w . -m gpt-4o-mini "Run ruff check . to find lint errors. Fix all errors. Run ruff again to verify."What happens:
- Agent runs
ruff check . - Reads the error output
- Fixes each issue (unused imports, whitespace, etc.)
- Reruns ruff until clean
7. Implement Temperature Conversion
Implement the reverse conversion function.
praisonai chat -w . -m gpt-4o-mini "Implement fahrenheit_to_celsius in converter.py. Formula: C = (F - 32) * 5/9. Run pytest -k fahrenheit."What happens:
- Agent implements the function
- Runs targeted tests
- Fixes any precision issues
8. Fix Median Edge Case
Handle empty list in median function.
praisonai chat -w . -m gpt-4o-mini "Fix median() in stats.py to raise ValueError('Cannot calculate median of empty list') for empty input. Run pytest -k median."What happens:
- Agent adds the validation check
- Runs tests to verify
- Ensures existing tests still pass
9. Add Type Hints
Improve code with type annotations.
praisonai chat -w . -m gpt-4o-mini "Add type hints to all methods in calculator.py. Example: def add(self, a: float, b: float) -> float:"What happens:
- Agent reads the file
- Adds parameter and return type hints
- Optionally runs mypy to verify
10. Make All Tests Pass
Fix all remaining issues in a project.
praisonai chat -w . -m gpt-4o-mini "Run pytest to see failing tests. Fix each one by implementing missing functions and fixing bugs. Keep going until ALL tests pass."What happens:
- Agent runs full test suite
- Identifies all failures
- Fixes each one systematically
- Reruns until 100% pass
Key Flags
| Flag | Description |
|---|---|
-w, --workspace | Set working directory for file operations |
-m, --model | LLM model to use (default: provider-aware — falls back to gpt-4o-mini when no credential is set; see Models → Provider Auto-Detection) |
-c, --continue | Continue previous session |
-f, --file | Attach file(s) to prompt |
-s, --session | Resume specific session ID |
The Closed-Loop Workflow
PraisonAI implements a closed-loop workflow similar to OpenCode:
Agent → Edit File → Run Tests → Read Output → Fix → RepeatThis means:
- The agent runs commands itself (not you)
- The agent reads test output itself
- The agent iterates until success
Tips for Best Results
- Use Workspace Flag: Always use
-w .to enable file editing - Be Specific: Include file paths and expected behavior
- Request Verification: Ask the agent to run tests after changes
- Use Cheap Models: Start with
gpt-4o-minifor cost efficiency - Continue Sessions: Use
--continuefor multi-step tasks
Troubleshooting
Agent Not Editing Files
Ensure you’re using the workspace flag:
praisonai chat -w . "your prompt"Tests Not Running
Make sure pytest is installed in your environment:
pip install pytestAPI Key Issues
Set your API key:
export OPENAI_API_KEY=your-key-hereUnicodeDecodeError on Windows
Windows subprocess operations require UTF-8 encoding:
$env:PYTHONIOENCODING = "utf-8"praisonai code hangs on Windows
Add the --no-acp flag for Windows automation:
praisonai code -w . --no-acp "your prompt"Import errors when chaining PYTHONPATH
Use the correct separator for your platform. On Windows use ;, on Unix use :, or use os.pathsep in Python scripts:
import os
paths = ["path1", "path2"]
pythonpath = os.pathsep.join(paths)Related
- Interactive Runtime – Core runtime details
- Session Management – Session commands
- Chat Command – Chat mode options