Skip to main content

Run prompts sequentially to tidy large code bases using Claude Code

Project description

Prompter

A Python tool for running prompts sequentially to tidy large code bases using Claude Code SDK.

PyPI version Python 3.11+ License: MIT

Requirements

  • Python 3.11 or higher
  • Claude Code SDK

Installation

Install from PyPI:

pip install claude-code-prompter

Or install from source:

# Install the package
pip install -e .

# Install with development dependencies
pip install -e ".[dev]"

Usage

Basic Commands

# Run all tasks from a configuration file
prompter config.toml

# Dry run to see what would be executed without making changes
prompter config.toml --dry-run

# Run a specific task by name
prompter config.toml --task fix_warnings

# Check current status and progress
prompter --status

# Clear saved state for a fresh start
prompter --clear-state

# Enable verbose output for debugging
prompter config.toml --verbose

# Save logs to a file
prompter config.toml --log-file debug.log

Common Use Cases

1. Code Modernization

# Create a config file for updating deprecated APIs
cat > modernize.toml << EOF
[settings]
working_directory = "/path/to/your/project"

[[tasks]]
name = "update_apis"
prompt = "Update all deprecated API calls to their modern equivalents"
verify_command = "python -m py_compile *.py"
on_success = "next"
on_failure = "retry"
max_attempts = 2

[[tasks]]
name = "add_type_hints"
prompt = "Add missing type hints to all functions and methods"
verify_command = "mypy --strict ."
on_success = "stop"
EOF

# Run the modernization
prompter modernize.toml

2. Documentation Updates

# Keep docs in sync with code changes
cat > docs.toml << EOF
[[tasks]]
name = "update_docstrings"
prompt = "Update all docstrings to match current function signatures and behavior"
verify_command = "python -m doctest -v *.py"

[[tasks]]
name = "update_readme"
prompt = "Update README.md to reflect recent API changes and new features"
verify_command = "markdownlint README.md"
EOF

prompter docs.toml --dry-run  # Preview changes first
prompter docs.toml            # Apply changes

3. Code Quality Improvements

# Fix linting issues and improve code quality
cat > quality.toml << EOF
[[tasks]]
name = "fix_linting"
prompt = "Fix all linting errors and warnings reported by flake8 and pylint"
verify_command = "flake8 . && pylint *.py"
on_failure = "retry"
max_attempts = 3

[[tasks]]
name = "improve_formatting"
prompt = "Improve code formatting and add missing blank lines for better readability"
verify_command = "black --check ."
EOF

prompter quality.toml

State Management

Prompter automatically tracks your progress:

# Check what's been completed
prompter --status

# Example output:
# Session ID: 1703123456
# Total tasks: 3
# Completed: 2
# Failed: 0
# Running: 0
# Pending: 1

# Resume from where you left off
prompter config.toml  # Automatically skips completed tasks

# Start fresh if needed
prompter --clear-state
prompter config.toml

Advanced Configuration

Task Dependencies and Flow Control

[settings]
working_directory = "/path/to/project"
check_interval = 30
max_retries = 3

# Task that stops on failure
[[tasks]]
name = "critical_fixes"
prompt = "Fix any critical security vulnerabilities"
verify_command = "safety check"
on_failure = "stop"  # Don't continue if this fails
max_attempts = 1

# Task that continues despite failures
[[tasks]]
name = "optional_cleanup"
prompt = "Remove unused imports and variables"
verify_command = "autoflake --check ."
on_failure = "next"  # Continue to next task even if this fails

# Task with custom timeout
[[tasks]]
name = "slow_operation"
prompt = "Refactor large legacy module"
verify_command = "python -m unittest discover"
timeout = 600  # 10 minutes

Multiple Project Workflow

# Process multiple projects in sequence
for project in project1 project2 project3; do
    cd "$project"
    prompter ../shared-config.toml --verbose
    cd ..
done

Configuration

Create a TOML configuration file with your tasks:

[settings]
check_interval = 30
max_retries = 3
working_directory = "/path/to/project"

[[tasks]]
name = "fix_warnings"
prompt = "Fix all compiler warnings in the codebase"
verify_command = "make test"
verify_success_code = 0
on_success = "next"
on_failure = "retry"
max_attempts = 3
timeout = 300

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

claude_code_prompter-0.1.5.tar.gz (27.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

claude_code_prompter-0.1.5-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file claude_code_prompter-0.1.5.tar.gz.

File metadata

  • Download URL: claude_code_prompter-0.1.5.tar.gz
  • Upload date:
  • Size: 27.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for claude_code_prompter-0.1.5.tar.gz
Algorithm Hash digest
SHA256 d8848572a5906da710dfdf8d6c21d24db9808ec34383a8874e648e29213302fe
MD5 4976734fd928bedd520a77b477f53de5
BLAKE2b-256 3124859f6f873682ee916ac49787f9a158c37c5111a9f13b46331f36a121fc4c

See more details on using hashes here.

Provenance

The following attestation bundles were made for claude_code_prompter-0.1.5.tar.gz:

Publisher: publish.yml on baijum/prompter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file claude_code_prompter-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for claude_code_prompter-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 8fba9aa54014e92d91c283c2b99d6f1b323fa6a7f754e1f9abb39377cb7dcb3e
MD5 cfe85bb28fa9c2d71638785cae4c11d7
BLAKE2b-256 626fc10a5439e453306495c460f7a483ed7e919238edbf8259c4f38c86786001

See more details on using hashes here.

Provenance

The following attestation bundles were made for claude_code_prompter-0.1.5-py3-none-any.whl:

Publisher: publish.yml on baijum/prompter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page