A Flask-based task management application that demonstrates integration with Claude Code for automated build failure analysis and fix suggestions.
- β Create, edit, complete, and delete tasks
- π·οΈ Categorize tasks (Work, Personal, Urgent, General)
- β Set priority levels (High, Medium, Low)
- π Filter and search tasks
- π Task statistics and visualizations
- πΎ Session-based storage (no database required)
- π GitHub Actions pipeline with automated testing and deployment
- π€ Claude Code integration for AI-powered build failure analysis
- π‘ Webhook endpoint for receiving build failure notifications
- π§ Automated fix suggestions for common issues
- π Pull request comments with AI-generated solutions
- π Admin dashboard for monitoring build failures
- Python 3.11+
- Flask and dependencies (see requirements.txt)
- GitHub repository for CI/CD
- Render account for deployment (optional)
- Anthropic API key for Claude integration (optional)
-
Clone the repository
git clone <your-repo-url> cd DemoClaudeCICD
-
Create virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Set environment variables (optional)
export FLASK_ENV=development export SECRET_KEY=your-secret-key export ANTHROPIC_API_KEY=your-anthropic-api-key
-
Run the application
python app.py
-
Access the application
- Main app: http://localhost:5000
- Admin dashboard: http://localhost:5000/admin
- Health check: http://localhost:5000/health
# Run all tests
pytest
# Run with coverage
pytest --cov=. --cov-report=html
# Run specific test file
pytest test_app.py -v# Format code
black .
# Sort imports
isort .
# Lint code
flake8 .
# Security scan
bandit -r . -x test_*.py-
Fork this repository
-
Create a new Web Service on Render
- Connect your GitHub repository
- Use the following settings:
- Environment: Python 3
- Build Command:
pip install -r requirements.txt - Start Command:
gunicorn --bind 0.0.0.0:$PORT app:app
-
Set environment variables
SECRET_KEY: Generate a secure random keyANTHROPIC_API_KEY: Your Claude API key (optional)FLASK_ENV: production
-
Configure GitHub Secrets
RENDER_SERVICE_ID: Your Render service IDRENDER_API_KEY: Your Render API keyRENDER_SERVICE_URL: Your deployed app URLWEBHOOK_URL: Your app URL +/webhook/build-failureANTHROPIC_API_KEY: Your Claude API key
The project includes two GitHub Actions workflows:
- Triggered on: Push to main/develop, Pull requests
- Steps:
- Code linting and formatting checks
- Unit tests with coverage reporting
- Security scanning
- Application startup test
- Deployment to Render (main branch only)
- Triggered on: CI/CD pipeline failure
- Steps:
- Captures workflow logs and error details
- Sends data to Claude Code for analysis
- Posts AI-generated fix suggestions
- Creates GitHub issues or PR comments
- Optional Slack notifications
- Build Failure Detection: GitHub Actions detects pipeline failures
- Log Collection: Failure handler script collects error logs and context
- AI Analysis: Logs are sent to Claude Code API for analysis
- Fix Suggestions: AI generates specific, actionable fix recommendations
- Notification: Results are posted to webhook endpoint and stored in session
- Dashboard: Admin dashboard displays failures and suggestions
The claude_integration.py module provides:
- Error Analysis: Intelligent parsing of build logs
- Context Awareness: Considers repository and build environment
- Fallback Handling: Mock suggestions when API is unavailable
- Pattern Recognition: Common error pattern detection
POST /webhook/build-failure
Expected payload:
{
"error_logs": "string",
"build_context": {},
"repository": "string",
"branch": "string",
"commit_sha": "string"
}Response:
{
"status": "success",
"suggestions": "AI-generated fix suggestions",
"message": "Build failure processed"
}DemoClaudeCICD/
βββ app.py # Main Flask application
βββ claude_integration.py # Claude Code API integration
βββ requirements.txt # Python dependencies
βββ Procfile # Render deployment config
βββ render.yaml # Render service configuration
βββ test_app.py # Unit tests
βββ .gitignore # Git ignore rules
βββ README.md # Project documentation
βββ templates/ # HTML templates
β βββ base.html # Base template
β βββ index.html # Main task interface
β βββ edit_task.html # Task editing form
β βββ admin.html # Admin dashboard
βββ static/ # Static assets
β βββ style.css # Custom styles
β βββ script.js # Frontend JavaScript
βββ scripts/ # Utility scripts
β βββ failure_handler.py # GitHub Actions failure processor
βββ .github/workflows/ # GitHub Actions
βββ ci-cd.yml # Main CI/CD pipeline
βββ failure-notification.yml # Build failure handler
| Variable | Description | Required |
|---|---|---|
SECRET_KEY |
Flask session secret key | Yes |
ANTHROPIC_API_KEY |
Claude API key for AI features | No |
FLASK_ENV |
Flask environment (development/production) | No |
PORT |
Application port (set by Render) | No |
| Secret | Description |
|---|---|
RENDER_SERVICE_ID |
Render service identifier |
RENDER_API_KEY |
Render API key for deployments |
RENDER_SERVICE_URL |
Deployed application URL |
WEBHOOK_URL |
Webhook endpoint URL |
ANTHROPIC_API_KEY |
Claude API key |
SLACK_WEBHOOK_URL |
Optional Slack notifications |
| Endpoint | Method | Description |
|---|---|---|
/ |
GET | Main task management interface |
/add_task |
POST | Create new task |
/complete_task/<id> |
POST | Mark task as complete |
/delete_task/<id> |
POST | Delete task |
/edit_task/<id> |
GET/POST | Edit task form |
/api/stats |
GET | Task statistics JSON |
/webhook/build-failure |
POST | Build failure webhook |
/admin |
GET | Admin dashboard |
/health |
GET | Health check endpoint |
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
This project is open source and available under the MIT License.
For issues and questions:
- Check the Issues page
- Review the admin dashboard for build failures
- Check GitHub Actions logs for CI/CD issues