Skip to content

Commit ef5520b

Browse files
andrewm4894claude
andcommitted
Enhance CLAUDE.md with comprehensive development guidance
Add detailed documentation for future Claude Code instances: - Add Documentation Commands section with Docusaurus workflow - Expand Testing & Quality section with all test commands - Add comprehensive Fly.io deployment commands section - Enhance Reset & Cleanup Operations with all cleanup levels - Add Container Architecture section explaining 3-container design - Expand Jobs Workflow from 5 to all 12 job types - Add Dagster Sensors section documenting monitoring sensors - Enhance Database Seeding & Examples with command references - Improve Entry Points with config.py documentation - Expand Metric Examples with 26+ available examples 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 82be00c commit ef5520b

File tree

1 file changed

+74
-14
lines changed

1 file changed

+74
-14
lines changed

CLAUDE.md

Lines changed: 74 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,25 @@ Anomstack is an open-source anomaly detection system built on Dagster and FastHT
2727
- `make docker-stop` - Stop all containers
2828

2929
### Testing & Quality
30-
- `pytest` or `make tests` - Run test suite
31-
- `make pre-commit` - Run pre-commit hooks (ruff linting)
30+
- `pytest` or `make tests` - Run test suite (includes documentation link checking)
31+
- `make test-examples` - Run only example ingest function tests
3232
- `make coverage` - Run tests with coverage report
33+
- `make pre-commit` - Run pre-commit hooks (ruff linting)
34+
35+
### Documentation Commands
36+
- `make docs` or `make docs-start` - Start Docusaurus dev server with live reload
37+
- `make docs-build` - Build static documentation site (includes broken link checking)
38+
- `make docs-test` - Test documentation for broken links
39+
- `make docs-serve` - Serve built documentation locally
40+
- `make docs-clear` - Clear documentation build cache
41+
- `make docs-install` - Install documentation dependencies
3342

34-
### Database Seeding
43+
### Database Seeding & Examples
3544
- `make seed-local-db` - Seed local DB with python_ingest_simple data
3645
- `make seed-local-db-all` - Seed with all example metric batches
3746
- `make seed-local-db-custom BATCHES='batch1,batch2' DB_PATH='path/to/db'`
47+
- `make run-example EXAMPLE=<name>` - Test individual example ingest functions
48+
- `make list-examples` - List all 26+ available examples
3849

3950
### Configuration & Hot Reload
4051
- `make reload-config` - Reload configuration without restarting containers
@@ -44,11 +55,40 @@ Anomstack is an open-source anomaly detection system built on Dagster and FastHT
4455
### Reset & Cleanup Operations
4556
- `make reset-interactive` - Interactive reset with guided options
4657
- `make reset-gentle` - Rebuild containers (safest reset)
47-
- `make reset-nuclear` - Remove everything including data
48-
- `make dagster-cleanup-standard` - Clean up old Dagster runs
58+
- `make reset-medium` - Remove containers, keep data volumes
59+
- `make reset-nuclear` - Remove everything including local data
60+
- `make reset-full-nuclear` - Nuclear + full docker system cleanup (maximum cleanup)
61+
- `make dagster-cleanup-status` - Show current Dagster storage usage
62+
- `make dagster-cleanup-minimal` - Remove old logs only (safe)
63+
- `make dagster-cleanup-standard` - Clean up old Dagster runs (older than 30 days)
64+
- `make dagster-cleanup-aggressive` - Remove runs older than 7 days
65+
- `make kill-long-runs` - Manually kill any Dagster runs exceeding configured timeout
66+
67+
### Fly.io Deployment Commands
68+
- `make fly-preview` - Preview environment variables that will be set as Fly secrets
69+
- `make fly-deploy` - Deploy to Fly.io (reads .env file automatically)
70+
- `make fly-deploy-demo` - Deploy with demo profile (enables demo metric batches)
71+
- `make fly-deploy-production` - Deploy with production profile
72+
- `make fly-deploy-development` - Deploy with development profile (all examples enabled)
73+
- `make fly-deploy-demo-fresh` - Deploy with fresh build (clears Docker cache first)
74+
- `make fly-build-test` - Test Fly.io build locally before deploying
75+
- `make fly-docker-clean` - Clean Docker cache for Fly builds
76+
- `make fly-cleanup` - Run disk cleanup on Fly instance (requires SSH access)
77+
- `make fly-cleanup-preview` - Preview cleanup on Fly instance (dry run)
78+
- `make fly-status` - Check Fly.io app status (requires FLY_APP env var)
79+
- `make fly-logs` - View Fly.io app logs (requires FLY_APP env var)
80+
- `make fly-ssh` - SSH into Fly.io app (requires FLY_APP env var)
4981

5082
## Architecture
5183

84+
### Container Architecture
85+
Anomstack uses a simplified 3-container Docker architecture:
86+
- **anomstack_webserver**: Consolidated Dagster webserver with embedded user code (no separate gRPC server)
87+
- **anomstack_daemon**: Dagster daemon for job scheduling and execution
88+
- **anomstack_dashboard**: FastHTML dashboard for metrics visualization
89+
90+
This consolidated approach eliminates the previous gRPC code server, reducing network overhead and improving reliability through direct Python module loading.
91+
5292
### Core Components
5393
- **anomstack/**: Main application code
5494
- `main.py`: Dagster definitions and job orchestration
@@ -71,9 +111,22 @@ Metrics are organized into "batches" - collections of related metrics with share
71111
### Jobs Workflow
72112
1. **Ingest**: Run SQL/Python to collect metrics
73113
2. **Train**: Train PyOD anomaly detection models
74-
3. **Score**: Score new data points for anomalies
114+
3. **Score**: Score new data points for anomalies
75115
4. **Alert**: Send email/Slack alerts for detected anomalies
76-
5. **Plot**: Generate visualizations in Dagster UI
116+
5. **LLM Alert**: LLM-based anomaly detection and alerting using anomaly-agent
117+
6. **Plot**: Generate visualizations in Dagster UI
118+
7. **Change**: Change detection for metrics
119+
8. **Summary**: Daily summary emails
120+
9. **Delete**: Delete old metrics
121+
10. **Reload**: Configuration hot-reload job
122+
11. **Cleanup**: Disk space management
123+
12. **Retention**: Custom retention for SQLite
124+
125+
### Dagster Sensors
126+
Three key sensors monitor the system:
127+
1. **email_on_run_failure**: Sends email notifications when Dagster runs fail
128+
2. **kill_long_running_runs**: Automatically terminates runs exceeding configured timeout (default 15 minutes, configurable via `ANOMSTACK_KILL_RUN_AFTER_MINUTES`)
129+
3. **config_file_watcher**: Smart file watcher that detects configuration changes and triggers reloads (enabled via `ANOMSTACK_CONFIG_WATCHER=true`)
77130

78131
### Database Storage
79132
All data stored in long-format "metrics" table with columns:
@@ -106,9 +159,10 @@ ANOMSTACK__PYTHON_INGEST_SIMPLE__ALERT_METHODS=email
106159
- `metrics/defaults/defaults.yaml`: Default parameters for all metric batches
107160
- `pyproject.toml`: Ruff linting configuration
108161

109-
### Entry Points
110-
- `anomstack/main.py`: Main Dagster definitions
162+
### Entry Points
163+
- `anomstack/main.py`: Main Dagster definitions (defines all jobs, schedules, and sensors)
111164
- `dashboard/app.py`: FastHTML dashboard application
165+
- `anomstack/config.py`: Configuration loading and environment variable override logic
112166

113167
### Database Connectors
114168
- `anomstack/external/`: Connectors for BigQuery, Snowflake, ClickHouse, DuckDB, SQLite
@@ -126,9 +180,8 @@ ANOMSTACK__PYTHON_INGEST_SIMPLE__ALERT_METHODS=email
126180

127181
### Testing
128182
- Tests in `tests/` directory
129-
- Use `pytest` or `make tests` for running tests
130-
- `make test-examples` - Run only example ingest function tests
131183
- Test coverage tracking with badges in README
184+
- See "Testing & Quality" section for test commands
132185

133186
### Deployment Options
134187
- Local Python environment
@@ -141,8 +194,15 @@ ANOMSTACK__PYTHON_INGEST_SIMPLE__ALERT_METHODS=email
141194
The `metrics/examples/` directory contains ready-to-use examples:
142195
- HackerNews story metrics via API
143196
- Weather data from Open Meteo
144-
- Stock prices from Yahoo Finance
197+
- Stock prices from Yahoo Finance (yfinance)
145198
- System metrics from Netdata
146-
- Simple Python-generated test metrics
199+
- Simple Python-generated test metrics (python_ingest_simple)
200+
- Earthquake data from USGS
201+
- ISS location tracking
202+
- PostHog analytics (requires credentials)
203+
- Currency exchange rates
204+
- And 26+ total examples
205+
206+
When adding new metrics, follow existing patterns in examples and ensure proper `.yaml` configuration with required fields like `metric_batch`, `db`, and cron schedules.
147207

148-
When adding new metrics, follow existing patterns in examples and ensure proper `.yaml` configuration with required fields like `metric_batch`, `db`, and cron schedules.
208+
Use `make run-example EXAMPLE=<name>` to test individual examples or `make list-examples` to see all available examples.

0 commit comments

Comments
 (0)