This guide covers setting up Watchflow for complete end-to-end local development, including GitHub App configuration, webhook setup, and API integration. For direction and supported logic, see README and docs.
Personal GitHub App vs. Marketplace App: For local development, creating your own GitHub App instead of using the production Watchflow app from the marketplace provides several critical advantages:
- Isolated development environment: Your local testing won't interfere with production Watchflow instances
- Full control over webhooks: You can point webhooks to your local ngrok tunnel instead of production servers
- Custom configuration: You can modify permissions and settings without affecting the production app
- Safe experimentation: Test new features, rule changes, and integrations without risk to live systems
- Independent debugging: Monitor webhook deliveries and debug issues in isolation
- No rate limiting conflicts: Avoid hitting GitHub API rate limits that might affect production usage
ngrok for Local Development: Since GitHub webhooks need to reach your local development server, and your localhost isn't accessible from the internet, ngrok creates a secure tunnel that:
- Exposes your local server to GitHub's webhook delivery system
- Provides HTTPS endpoints required by GitHub for webhook URLs
- Offers request inspection tools to debug webhook payloads
- Eliminates complex firewall configuration or port forwarding
- Python 3.12 or higher
- uv package manager (recommended) or pip
- ngrok installed for webhook tunneling
- GitHub organization or user account with admin access
- OpenAI API key for AI agent functionality
- LangSmith account for AI agent debugging (optional)
- Navigate to your GitHub organization settings or personal settings
- Go to "Developer settings" → "GitHub Apps" → "New GitHub App"
- Fill in the basic app information:
- App name:
watchflow-dev(or your preferred name) - Homepage URL:
http://localhost:8000 - Webhook URL:
https://placeholder.ngrok.io/webhooks/github(we'll update this in Step 3) - Webhook secret: Generate a secure random string and save it
- Description: "Local development instance of Watchflow"
- App name:
Set the following permissions for your GitHub App:
- Actions: Read-only
- Checks: Read and write
- Contents: Read-only
- Deployments: Read and write
- Environments: Read-only
- Issues: Read and write
- Metadata: Read-only (mandatory)
- Pull requests: Read and write
- Commit statuses: Read and write
- Members: Read-only
Check the following webhook events:
- ✅ Check run
- ✅ Commit comment
- ✅ Deployment
- ✅ Deployment protection rule
- ✅ Deployment review
- ✅ Deployment status
- ✅ Issue comment
- ✅ Issues
- ✅ Pull request
- ✅ Pull request review
- ✅ Pull request review comment
- ✅ Pull request review thread
- ✅ Push
- ✅ Status
- ✅ Workflow dispatch
- ✅ Workflow job
- ✅ Workflow run
- After creating the app, scroll down to "Private keys"
- Click "Generate a private key"
- Download the
.pemfile and save it securely - Note down your App ID from the app settings page
git clone https://github.com/watchflow/watchflow.git
cd watchflowUsing uv (recommended):
# Create and activate virtual environment
uv venv
source .venv/bin/activate # On macOS/Linux
# or
.venv\Scripts\activate # On Windows
# Install dependencies
uv syncOr using pip:
# Create virtual environment
python -m venv .venv
# Activate virtual environment
source .venv/bin/activate # On macOS/Linux
# or
.venv\Scripts\activate # On Windows
# Install dependencies
pip install -e ".[dev]"# Install ngrok
# On macOS with Homebrew:
brew install ngrok
# On other systems, download from https://ngrok.com/download
# Start ngrok tunnel to your local API
ngrok http 8000Copy the ngrok HTTPS URL from the terminal output (e.g., https://abc123.ngrok.io)
- Go back to your GitHub App settings
- Update the Webhook URL to:
https://your-ngrok-url.ngrok.io/webhooks/github - Save the changes
cp .env.example .envEdit your .env file with the following configuration:
# GitHub Configuration (required)
APP_NAME_GITHUB=watchflow-dev
APP_CLIENT_ID_GITHUB=your_app_id_from_github_app_settings
APP_CLIENT_SECRET_GITHUB=your_client_secret_from_github_app_settings
PRIVATE_KEY_BASE64_GITHUB=your_base64_encoded_private_key
WEBHOOK_SECRET_GITHUB=your_webhook_secret_from_step_1
# AI Provider Selection
AI_PROVIDER=openai # Options: openai, bedrock, vertex_ai
# Common AI Settings (defaults for all agents)
AI_MAX_TOKENS=4096
AI_TEMPERATURE=0.1
# OpenAI Configuration (when AI_PROVIDER=openai)
OPENAI_API_KEY=your_openai_api_key_here
OPENAI_MODEL=gpt-4.1-mini # Optional, defaults to gpt-4.1-mini
# Engine Agent Configuration
AI_ENGINE_MAX_TOKENS=8000 # Default: 8000
AI_ENGINE_TEMPERATURE=0.1
# Feasibility Agent Configuration
AI_FEASIBILITY_MAX_TOKENS=4096
AI_FEASIBILITY_TEMPERATURE=0.1
# Acknowledgment Agent Configuration
AI_ACKNOWLEDGMENT_MAX_TOKENS=2000
AI_ACKNOWLEDGMENT_TEMPERATURE=0.1
# LangSmith Configuration
LANGCHAIN_TRACING_V2=false
LANGCHAIN_ENDPOINT=https://api.smith.langchain.com
LANGCHAIN_API_KEY=your_langsmith_api_key
LANGCHAIN_PROJECT=watchflow-dev
# CORS Configuration
CORS_HEADERS=["*"]
CORS_ORIGINS=["http://localhost:3000", "http://127.0.0.1:3000", "http://localhost:5500", "https://warestack.github.io", "https://watchflow.dev"]
# Repository Configuration
REPO_CONFIG_BASE_PATH=.watchflow
REPO_CONFIG_RULES_FILE=rules.yaml
# Logging Configuration
LOG_LEVEL=INFO
LOG_FORMAT=%(asctime)s - %(name)s - %(levelname)s - %(message)s
# Development Settings
DEBUG=false
ENVIRONMENT=developmentConvert your GitHub App private key to base64:
Option 1: Using command line (recommended):
# Encode the private key file
cat /path/to/your-private-key.pem | base64 | tr -d '\n'Option 2: Using online tools:
If you prefer using a web interface, you can use online base64 encoding tools like base64encode.org:
- Open the
.pemfile in a text editor - Copy the entire content (including the BEGIN/END lines)
- Paste it into the online encoder
- Copy the base64 output
Copy the base64 output and use it as the value for PRIVATE_KEY_BASE64_GITHUB in your .env file.
Security Note: When using online tools, ensure you're using a reputable service and understand that your private key content will be processed by their servers. For maximum security, prefer the command-line method.
- In your GitHub App settings, click on "Install App" in the left sidebar
- Choose to install on your organization or personal account
- Select "Selected repositories" and choose the repositories you want to monitor
- Alternatively, select "All repositories" for organization-wide installation
- Click "Install" to complete the installation
- Go to the repository settings of an installed repository
- Navigate to "Integrations" → "GitHub Apps"
- Verify that your
watchflow-devapp is listed and active
# Using uv (recommended)
uv run uvicorn src.main:app --reload --host 0.0.0.0 --port 8000
# Using pip
uvicorn src.main:app --reload --host 0.0.0.0 --port 8000The API will be available at http://localhost:8000
Open your browser and navigate to:
http://localhost:8000/docs- Interactive API documentationhttp://localhost:8000/health- Health check endpoint
- Ensure your local API is running on port 8000
- Verify ngrok tunnel is active and forwarding to localhost:8000
- Check the ngrok dashboard at
http://localhost:4040for incoming requests
- Go to one of your monitored repositories
- Create a new pull request or push a commit
- Check your local API logs to confirm webhook events are being received
- Monitor the ngrok dashboard for incoming webhook requests
💡 Tip: You can test your natural language rules at watchflow.dev to see if they're supported and get the generated YAML configuration. Then copy and paste it into your repository's rules.yaml file.
Create a test rule in a monitored repository by adding .watchflow/rules.yaml:
rules:
- description: Simple rule to test local setup
enabled: true
severity: medium
event_types: [pull_request]
parameters:
test_param: "local_test"
- description: All pull requests must have at least 1 approval
enabled: true
severity: high
event_types: [pull_request]
parameters:
min_approvals: 1- Verify ngrok is running and the URL is correct in GitHub App settings
- Check that the webhook secret matches your environment configuration
- Ensure your local API endpoint
/webhooks/githubis properly configured - Check GitHub App webhook delivery logs in the app settings
- Double-check that all required permissions are granted to the GitHub App
- Verify the app is installed on the correct repositories/organization
- Ensure the private key is correctly encoded and configured
- Free ngrok tunnels expire after 8 hours
- Restart ngrok and update the webhook URL in your GitHub App settings
- Consider upgrading to ngrok Pro for persistent URLs
- Verify your OpenAI API key is valid and has sufficient credits
- Check the AI model name in your configuration
- Review API logs for OpenAI-related errors
Monitor the following for debugging:
- Local API server logs - Check your terminal running uvicorn
- ngrok request logs - Run
ngrok http 8000 --log=stdout - GitHub App webhook delivery logs - Available in GitHub App settings
- LangSmith traces - If configured, view at LangSmith Dashboard
# Check if API is responding
curl http://localhost:8000/health
# Test rule evaluation endpoint
curl -X POST "http://localhost:8000/api/v1/rules/evaluate" \
-H "Content-Type: application/json" \
-d '{
"rule_text": "All pull requests must have at least 2 approvals"
}'
# View detailed logs
tail -f logs/watchflow.log- Never commit your private keys or webhook secrets to version control
- Use environment variables or secure secret management for all credentials
- Rotate webhook secrets periodically
- Limit GitHub App installation scope to only necessary repositories during development
- Keep your ngrok tunnel URL private and don't share it publicly
- Use separate GitHub Apps for development and production environments
Once your local setup is working:
- Explore the API documentation at
http://localhost:8000/docs - Create custom rules in your test repositories
- Set up LangSmith for AI agent debugging and monitoring
- Run the test suite to verify everything is working:
pytest - Read the main development guide in
DEVELOPMENT.mdfor advanced topics
After completing this setup, you can integrate with the standard development workflow:
# Format and lint code
uv run ruff format src/
uv run ruff check src/
# Run tests
pytest
# Install pre-commit hooks for code quality
uv run pre-commit install
uv run pre-commit install --hook-type commit-msgFor more advanced development topics, testing strategies, and deployment options, refer to the main DEVELOPMENT.md guide.