HEX
Server: LiteSpeed
System: Linux houston.panomity.com 6.8.0-100-generic #100-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 13 16:40:06 UTC 2026 x86_64
User: nudepix (1011)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //opt/PraisonAI/docs/agents/programming.mdx
---
title: "Programming Agent"
sidebarTitle: "Programming"
description: "Learn how to create AI agents for code development, analysis, and execution."
icon: "code"
---

```mermaid
flowchart LR
    In[Code Request] --> Analyzer[Code Analyzer]
    Analyzer --> Generator[Code Generator]
    Generator --> Executor[Code Executor]
    Executor --> Debugger[Code Debugger]
    Debugger --> Out[Output]
    
    style In fill:#8B0000,color:#fff
    style Analyzer fill:#2E8B57,color:#fff
    style Generator fill:#2E8B57,color:#fff
    style Executor fill:#2E8B57,color:#fff
    style Debugger fill:#2E8B57,color:#fff
    style Out fill:#8B0000,color:#fff
```

A workflow demonstrating how the Programming Agent can analyze, generate, execute, and debug code.

## Quick Start

<Steps>
    <Step title="Install Package">
        First, install the PraisonAI Agents package:
        ```bash
        pip install praisonaiagents
        ```
    </Step>

    <Step title="Set API Key">
        Set your OpenAI API key as an environment variable:
        ```bash
        export OPENAI_API_KEY=your_api_key_here
        ```
    </Step>

    <Step title="Create Script">
        Create a new file `code_assistant.py`:
        ```python
        from praisonaiagents import Agent, Tools
        from praisonaiagents.tools import execute_code, analyze_code, format_code, lint_code, disassemble_code # Code Tools
        from praisonaiagents.tools import execute_command, list_processes, kill_process, get_system_info # Shell Tools
        from praisonaiagents.tools import duckduckgo # Web Search Tool

        agent = Agent(
            instructions="You are a Programming Agent", self_reflect=True, min_reflect=5, max_reflect=10, 
            tools=[execute_code, analyze_code, format_code, lint_code, disassemble_code, execute_command, list_processes, kill_process, get_system_info, duckduckgo]
        )
        agent.start(
            "Write a python script using yfinance to find the stock price of Tesla"
            "First check if required packages are installed"
            "Run it using execute_code"
            "execute_command if you want to run any terminal command"
            "search internet using duckduckgo if you want to know update python package information"
            "Analyse the output using analyze_code and fix error if required"
            "if no package is installed, install it"
            "then run the code"
        )
        ```
    </Step>
</Steps>

## Understanding Code Development

The Programming Agent combines multiple tools for comprehensive code development:

1. **Code Tools**:
   - `execute_code`: Run Python code
   - `analyze_code`: Analyze code structure
   - `format_code`: Format code to standards
   - `lint_code`: Check code quality
   - `disassemble_code`: View bytecode

2. **Shell Tools**:
   - `execute_command`: Run terminal commands
   - `list_processes`: View running processes
   - `kill_process`: Terminate processes
   - `get_system_info`: System information

3. **Web Tools**:
   - `duckduckgo`: Search for programming resources

## Features

<CardGroup cols={2}>
  <Card title="Code Execution" icon="play">
    Run and test code directly.
  </Card>
  <Card title="Code Analysis" icon="magnifying-glass-code">
    Analyze and improve code quality.
  </Card>
  <Card title="System Integration" icon="terminal">
    Execute system commands and manage processes.
  </Card>
  <Card title="Package Management" icon="box">
    Handle dependencies and installations.
  </Card>
</CardGroup>

## Example Usage

```python
# Example: Create and run a data analysis script
response = agent.start("""
    1. Create a script that:
       - Uses pandas for data analysis
       - Reads a CSV file
       - Performs basic statistics
       - Creates a visualization
    2. Check and install required packages
    3. Execute and analyze the results
""")
```

## Next Steps

- Learn about [Prompt Chaining](/features/promptchaining) for complex development workflows
- Explore [Evaluator Optimizer](/features/evaluator-optimiser) for improving code quality
- Check out the [Data Analyst Agent](/agents/data-analyst) for specialized data analysis