1. PyDemoAgent
PyDemoAgent is an interactive development agent powered by the Anthropic Claude API.
Point it at a source directory and ask questions, request analysis, or generate documentation
through a conversational interface. Conversation history is maintained across turns so
follow-up questions stay coherent.
1.1 Requirements
| Requirement |
Details |
| Python |
3.7 or later |
| anthropic package |
anthropic>=0.39.0 - installed automatically by the launch scripts |
| API key |
Anthropic API key from
console.anthropic.com
|
1.2 Setup
Set the API key before the first run. The launch scripts prompt for it if it is not found.
# Windows CMD - permanent
setx ANTHROPIC_API_KEY your-key-here
# Windows PowerShell - permanent
[System.Environment]::SetEnvironmentVariable('ANTHROPIC_API_KEY','your-key-here','User')
# Linux / macOS
export ANTHROPIC_API_KEY='your-key-here'
To install the dependency manually without a launch script:
pip install -r requirements.txt
1.3 Running
On Windows the easiest approach is the batch launcher. It checks for Python, verifies
or prompts for the API key, installs dependencies, and launches the agent:
run_agent.bat [path]
Or right-click run_agent.ps1 and choose Run with PowerShell.
To launch directly:
python dev_agent.py [directory] [options]
directory defaults to the current working directory if omitted.
1.4 CLI Options
| Option |
Description |
directory |
Root of the codebase to analyze (default: .) |
--api-key KEY |
API key (overrides ANTHROPIC_API_KEY env var) |
--model MODEL |
Claude model ID to use |
--analyze FILE |
Analyze one file and exit (one-shot mode) |
--improve |
Print improvement suggestions and exit |
--readme |
Generate a README for the project and exit |
1.5 Interactive Commands
Once running, type these at the prompt. Any other input is sent to Claude as a
free-form question about the codebase.
| Command |
Action |
/analyze <file> |
Deep analysis of a specific file |
/improve |
Architectural and code quality suggestions |
/readme |
Generate a README for the target codebase |
/tree |
Print the directory tree |
/files |
List all detected source files |
/clear |
Reset conversation history |
/quit |
Exit |
1.6 How It Works
The agent is implemented as a single SoftwareDevAgent class in
dev_agent.py. On the first message it builds a file tree and codebase
statistics - file counts, line counts, language distribution - and includes them in
the context sent to Claude. Subsequent messages reuse the cached context, keeping
token use efficient.
Source files are discovered by extension. Supported languages: Python, JavaScript,
TypeScript, Java, C++, C, C#, Rust, Go, Ruby, PHP, and JSX/TSX variants. These
directories are excluded from scans:
__pycache__, node_modules, .git,
bin, obj, build, dist
Path inputs are validated to prevent directory traversal outside the target root.
The API key is never logged or echoed.
1.7 Files
| File |
Purpose |
dev_agent.py |
Agent implementation and CLI entry point (SoftwareDevAgent class) |
requirements.txt |
Python dependencies (anthropic>=0.39.0) |
run_agent.bat |
Windows batch launcher - checks Python, API key, installs deps |
run_agent.ps1 |
Windows PowerShell launcher |
USAGE.md |
Extended usage guide with examples |
WINDOWS_SETUP.md |
Windows-specific setup notes |
1.8 References