Product Name: Sawmill
Version: 1.0
Last Updated: August 16, 2025
Sawmill is an automated log analysis tool that monitors Railway services, analyzes logs using Claude AI, and sends intelligent alerts via Telegram and email. When critical errors are detected, the tool can automatically create GitHub issues in the appropriate repositories. The tool runs as a scheduled service, periodically collecting logs from multiple Railway projects, processing them through Anthropic's language models for anomaly detection and insights, then delivering actionable notifications and creating trackable issues.
Provide proactive monitoring and intelligent analysis of Railway application logs to help developers identify issues, track deployment health, and receive contextual alerts without manual log inspection.
- DevOps engineers managing Railway deployments
- Development teams using Railway for production services
- Platform engineers responsible for service reliability
- Automated Intelligence: Transform raw logs into actionable insights using AI
- Multi-Project Support: Monitor multiple Railway projects from a single tool
- Proactive Alerting: Get notified of issues before they become critical
- Contextual Analysis: Receive summaries and recommendations, not just raw alerts
- Automated Issue Tracking: Automatically create GitHub issues for detected problems
- Runtime: Node.js with TypeScript
- AI Integration: Anthropic SDK for Claude/Sonnet models
- Railway Integration: Railway CLI + Railway MCP Server
- Notifications: Grammy (Telegram Bot Framework)
- Scheduling: Cron jobs or similar scheduling mechanism
- Email: SMTP integration for email alerts
- GitHub Integration: Octokit SDK for automated issue creation
- Log Collector: Interfaces with Railway CLI/MCP to fetch logs
- AI Analyzer: Processes logs through Claude for insights
- Alert Manager: Handles notification routing and formatting
- GitHub Issue Manager: Creates and manages GitHub issues for detected problems
- Configuration Manager: Manages multi-project settings
- Scheduler: Manages periodic execution
- FR-1.1: Connect to multiple Railway projects using project tokens
- FR-1.2: Retrieve logs from specified time intervals (configurable)
- FR-1.3: Support filtering by service within projects
- FR-1.4: Handle authentication via RAILWAY_TOKEN environment variable
- FR-1.5: Cache and deduplicate logs to avoid reprocessing
- FR-2.1: Send collected logs to Claude/Sonnet models via Anthropic SDK
- FR-2.2: Implement configurable analysis prompts for different log types
- FR-2.3: Identify error patterns, anomalies, and performance issues
- FR-2.4: Generate human-readable summaries and recommendations
- FR-2.5: Support different analysis depths (quick scan vs. deep analysis)
- FR-3.1: Send alerts via Telegram using Grammy framework
- FR-3.2: Send alerts via email (SMTP)
- FR-3.3: Support different alert severity levels
- FR-3.4: Include log excerpts and AI analysis in alerts
- FR-3.5: Support alert throttling to prevent spam
- FR-4.1: Automatically create GitHub issues when critical errors are detected
- FR-4.2: Map Railway services to their corresponding GitHub repositories
- FR-4.3: Include AI analysis, log excerpts, and suggested fixes in issue descriptions
- FR-4.4: Support issue deduplication to prevent spam
- FR-4.5: Add appropriate labels and assign issues based on configuration
- FR-4.6: Link created issues in Telegram/email notifications
- FR-4.1: Support configuration file for multiple projects
- FR-4.2: Per-project customizable analysis prompts
- FR-4.3: Configurable alert thresholds and routing
- FR-4.4: Environment-based configuration (dev/staging/prod)
- FR-5.1: Run as scheduled cron job with configurable intervals
- FR-5.2: Support manual execution for testing
- FR-5.3: Graceful error handling and recovery
- FR-5.4: Logging and monitoring of tool execution
- NFR-1.1: Process logs for up to 10 Railway projects within 5 minutes
- NFR-1.2: Handle log volumes up to 100MB per execution cycle
- NFR-1.3: Minimize API calls to Anthropic to control costs
- NFR-2.1: 99% uptime for scheduled executions
- NFR-2.2: Graceful degradation when Railway or Anthropic APIs are unavailable
- NFR-2.3: Retry mechanisms for transient failures
- NFR-3.1: Secure storage of API tokens and credentials
- NFR-3.2: No logging of sensitive information
- NFR-3.3: Support for environment variable-based configuration
- NFR-4.1: Comprehensive TypeScript typing
- NFR-4.2: Modular architecture for easy testing
- NFR-4.3: Clear configuration documentation
- Railway CLI: Required for authentication and log access
- Railway MCP Server: Provides structured interface to Railway services
- Authentication: Project tokens via RAILWAY_TOKEN environment variable
- Models: Claude Sonnet 4 (primary), fallback to other Claude models
- Authentication: API key via ANTHROPIC_API_KEY environment variable
- Rate Limits: Must respect Anthropic's API rate limits
- Grammy Framework: TypeScript-first Telegram bot framework
- Bot Token: Required from @BotFather
- Message Limits: Respect Telegram's message size and rate limits
- Octokit SDK: Official TypeScript SDK for GitHub API
- Authentication: Personal Access Token or GitHub App credentials
- Rate Limits: Must respect GitHub's API rate limits (5000 requests/hour for authenticated users)
- Permissions: Requires 'issues:write' scope for creating issues
interface ProjectConfig {
name: string;
railwayToken: string;
services?: ServiceConfig[]; // Optional service filtering with GitHub mapping
analysisPrompt?: string; // Custom analysis instructions
logRetentionHours: number; // How far back to look
}
interface ServiceConfig {
name: string;
githubRepo?: {
owner: string;
repo: string;
defaultAssignees?: string[];
labels?: string[];
};
}interface AlertConfig {
telegram?: {
botToken: string;
chatId: string;
enabled: boolean;
};
email?: {
smtpHost: string;
smtpPort: number;
username: string;
password: string;
to: string[];
enabled: boolean;
};
github?: {
token: string;
enabled: boolean;
createIssueThreshold: 'medium' | 'high'; // Only create issues for these severity levels
deduplicationWindow: number; // Hours to check for similar issues
};
severityThreshold: 'low' | 'medium' | 'high';
}- US-1: I want to receive Telegram notifications when errors spike in my Railway services
- US-2: I want to get AI-generated summaries of deployment issues across multiple projects
- US-3: I want to configure different alert thresholds for different environments
- US-4: I want to receive weekly summaries of application health across all projects
- US-5: I want to identify performance degradation patterns before they impact users
- US-6: I want to understand the context around errors, not just that they occurred
- US-7: I want GitHub issues automatically created for critical errors with AI-generated descriptions and suggested fixes
- US-8: I want issues to be created in the correct repository based on which service had the error
- TM-1: Time to detect critical issues < 5 minutes after occurrence
- TM-2: False positive rate < 10%
- TM-3: Tool execution success rate > 95%
- UEM-1: Alert relevance score (user feedback) > 80%
- UEM-2: Time to resolution improvement of 25% for alerted issues
- UEM-3: User adoption across > 50% of Railway projects in organization
- Basic log collection from single Railway project
- Simple AI analysis with fixed prompts
- Telegram notifications
- Basic error handling
- Configuration system for multiple projects
- Enhanced authentication handling
- Email notification support
- GitHub issue creation functionality
- Advanced AI prompts and analysis
- Alert throttling and severity levels
- Performance optimizations
- Comprehensive testing
- Monitoring and logging
- Documentation
- Deployment automation
- Security review
- Risk: Railway MCP Server instability (marked as "experimental")
- Mitigation: Implement fallbacks to direct Railway CLI calls
- Risk: Anthropic API rate limits or costs
- Mitigation: Implement intelligent batching and cost monitoring
- Risk: Telegram API limitations
- Mitigation: Implement message queuing and rate limiting
- Risk: GitHub API rate limits
- Mitigation: Implement intelligent issue deduplication and rate limiting
- Risk: High false positive rate leading to alert fatigue
- Mitigation: Iterative prompt engineering and threshold tuning
- Risk: Missing critical issues due to AI hallucination
- Mitigation: Always include raw log excerpts with AI analysis
- Risk: Creating duplicate or spam GitHub issues
- Mitigation: Implement issue deduplication based on error patterns and time windows
- Web dashboard for historical analysis
- Integration with incident management tools
- Custom AI model fine-tuning
- Log pattern learning and adaptation
- Slack notifications
- Discord webhooks
- PagerDuty integration
- Advanced GitHub integration (issue assignment, project boards)
- GitHub Actions integration for automated responses
Document Prepared By: Claude Code Assistant
Review Status: Draft
Next Review Date: Upon implementation start