CLAUDE.md
CLAUDE.mdCLAUDE.mdroot
Quality
97/100
Scores the file, not the repository.Length
869 words
36 headings · 5 code blocksRepository
0
— · pushed 31 days agoLast changed
3 days ago
First indexed 3 days ago.1# CLAUDE.md23Network Connectivity Monitor - AI Agent Guidelines45## Project Overview67A Go-based network monitoring tool that performs continuous ping tests to detect ISP issues and connectivity patterns. Features intelligent data retention, pattern detection via heatmaps, and web-based visualization.89**Key Purpose**: Long-term ISP issue documentation with compelling visual evidence.1011## Architecture & Entry Points1213- **Main Entry**: `main.go` - Orchestrates all components with graceful shutdown14- **Internal Structure**: Clean separation via `internal/` packages15- **Static Assets**: Embedded via `//go:embed static/*` in main.go (production) or filesystem serving (development)16- **Database**: SQLite with WAL mode for concurrent access1718### Critical Components1920```plain21internal/22├── config/ - CLI flags and validation (config.go, flags.go)23├── database/ - SQLite operations, schema, maintenance (db.go, queries.go)24├── models/ - Data structures (ping.go, stats.go, types.go)25├── monitor/ - Worker orchestration and lifecycle (monitor.go, worker.go)26├── ping/ - Cross-platform ping implementation27├── report/ - PNG chart generation using go-chart/v228└── web/ - HTTP server and REST API (handlers.go, server.go)29```3031## Database Schema Strategy3233**Smart Retention Pattern**:3435- `ping_results`: Raw data (7-day retention)36- `hourly_patterns`: Aggregated for heatmap (90-day retention)37- `outages`: Detected failures (permanent)38- `hourly_stats`: Statistical summaries3940**Key Insight**: Maintenance runs hourly via `internal/database/maintenance.go` - automatic data aggregation and cleanup.4142## Build & Development Workflow4344### Essential Commands4546```bash47task build # Build after tests+lint (required for deployment)48task dev # Development server with live static file editing49task test # Run all tests50task lint # goimports + vet + golangci-lint51task build-linux # Cross-compile for Linux deployment52```5354### Development Mode for UI Work5556**Live Static File Editing**: The `task dev` command now enables live editing of HTML, CSS, and JavaScript files without server restarts.5758```bash59task dev # Runs: go run . --dev60```6162**Development Mode Features**:6364- **Live HTML editing**: Changes to `static/index.html` visible on browser refresh65- **Live CSS editing**: Modifications to `static/css/*.css` applied immediately66- **Live JavaScript editing**: Updates to `static/js/*.js` served instantly from filesystem67- **No server restart required**: Only browser refresh needed to see changes68- **Production safety**: Build process unchanged, still uses embedded files6970**Development vs Production**:7172- **Development** (`--dev` flag): Serves files from `static/` directory (live editing)73- **Production** (default): Uses embedded `//go:embed` files (compile-time)7475### UI Testing with Playwright7677**Automated UI Testing**: Use the general-purpose agent with Playwright browser automation for comprehensive UI testing.7879```bash80# Start development server in background81task dev8283# Use Task tool with browser automation to test UI changes84# The agent can:85# - Navigate to localhost:808086# - Take screenshots of UI components87# - Test hover interactions on heatmap cells88# - Verify responsive layout behavior89# - Test different time range selections90# - Validate tooltips and interactive elements91```9293**UI Development Workflow**:94951. Start development server: `task dev`962. Edit static files (HTML/CSS/JS) in your editor973. Refresh browser to see changes immediately984. Use Playwright agent to verify functionality995. Take screenshots for documentation/validation100101### Pre-commit Requirements102103- **Always run**: `task build` before considering changes complete104- **Format**: Uses `goimports -w .` (NOT gofmt) for imports management105- **Linting**: golangci-lint with `.golangci.yml` config106107## Project-Specific Conventions108109### Error Handling Pattern110111```go112// Preferred throughout codebase113if errors.Is(err, database.ErrOutageExists) {114 // handle specifically115}116```117118### Configuration Philosophy119120- CLI flags via `internal/config/flags.go`121- Validation in separate `config.Validate()` method122- Defaults optimized for home ISP monitoring123124### Ping Implementation Detail125126- Cross-platform: Windows/Mac/Linux support in `internal/ping/ping.go`127- **Outage Detection**: 5+ failures in any 10 consecutive pings128- Uses OS-native ping (not raw sockets) for reliability129130## Web Interface Integration131132### API Patterns133134- RESTful JSON endpoints in `internal/web/handlers.go`135- Real-time data serving for D3.js frontend136- **Key Route**: `/api/data` powers the heatmap visualization137138### Static Assets139140- Single `static/index.html` with embedded D3.js141- **Production Pattern**: All static files embedded at compile time via `//go:embed`142- **Development Pattern**: Files served directly from filesystem for live editing143- No build step for frontend - vanilla HTML/JS/CSS144- **Live Development**: Use `task dev` for immediate UI changes without server restart145146## Testing & CI/CD147148### Test Strategy149150- `*_test.go` files for critical functionality only151- **CI Pattern**: Separate test/lint/build jobs in GitHub Actions152- Uses `task test-ci` for coverage reporting153154### Docker Deployment155156- `Dockerfile` + `docker-compose.yml` for containerization157- **Volume Pattern**: `./data:/app/data` for database persistence158- Health checks via web interface availability159160## Integration Points161162### llm-shared Submodule163164- Development tools in `llm-shared/utils/`165- **Key Tool**: `gofuncs.go` for function analysis166- Project validation via `validate-docs.go`167168### External Dependencies169170- **Database**: `modernc.org/sqlite` (pure Go SQLite)171- **Charts**: `github.com/wcharczuk/go-chart/v2` for PNG report generation172- **Minimal Dependencies**: Prefers standard library173174## ISP Documentation Workflow175176### Data Collection Strategy1771781. **Hour 1**: Basic connectivity data1792. **Day 1**: Initial pattern recognition1803. **Week 1**: Clear time-of-day patterns1814. **Month 1**: Compelling evidence for ISP discussions182183### Report Generation184185- PNG charts via `internal/report/` package186- **Visual Evidence**: Heatmap screenshots after 1-2 weeks most effective187- Export capability for CSV data analysis188189## Development Notes190191- **Deployment Target**: Single-user, private monitoring (not SaaS)192- **Service Integration**: Includes launchd/systemd service examples in README193- **Resource Efficient**: <1% CPU, 20-50MB RAM with default settings194- **Cross-Platform**: Full macOS/Linux/Windows support with OS-specific deployment guides195
Also in lepinkainen/network-monitor
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| lepinkainen/network-monitor.clinerules/project-base.md · 0 | Cline rules | buildlint-formatstylearch+2 | 78/100 | 3 days ago | |
| lepinkainen/network-monitorAGENTS.md · 0 | AGENTS.md | buildteststylearch+3 | 90/100 | 3 days ago |
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| bagisto/bagistoCLAUDE.md · 28k | CLAUDE.md | setupbuildteststyle+5 | 100/100 | 3 days ago | |
| filamentphp/filamentCLAUDE.md · 32k | CLAUDE.md | buildtestlint-formatstyle+7 | 100/100 | 3 days ago | |
| Adit-Jain-srm/NightmareNetCLAUDE.md · 45 | CLAUDE.md | buildtestlint-formatstyle+6 | 100/100 | 3 days ago | |
| microsoft/playwrightCLAUDE.md · 94k | CLAUDE.md | buildtestlint-formatstyle+7 | 100/100 | 3 days ago | |
| nimbalyst/nimbalystpackages/android/CLAUDE.md · 1.4k | CLAUDE.md | setupbuildstylearch+2 | 100/100 | 3 days ago | |
| stacklok/toolhiveCLAUDE.md · 2.0k | CLAUDE.md | buildteststylearch+4 | 100/100 | 3 days ago | |
| dotCMS/corecore-web/CLAUDE.md · 950 | CLAUDE.md | teststylearchtesting-strategy+3 | 100/100 | 3 days ago | |
| livewire/livewireCLAUDE.md · 24k | CLAUDE.md | setupbuildteststyle+4 | 100/100 | 3 days ago |
