CLAUDE.md
CLAUDE.mdCLAUDE.mdroot
Quality
89/100
Scores the file, not the repository.Length
855 words
35 headings · 3 code blocksRepository
0
— · pushed 262 days agoLast changed
3 days ago
First indexed 3 days ago.1# CLAUDE.md23This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.4## Core Principles561. **Zero Duplication**: Always reuse or extend existing utilities instead of reimplementing72. **Code Discovery First**: Search the codebase thoroughly before writing new functions83. **Scope Discipline**: Edit only files required for the specific ticket94. **Single Responsibility**: One purpose per function105. **Atomic Commits**: One logical change per commit1112## What NOT to Do1314- **Build for imaginary future requirements** - Only implement what the current ticket requires15- **Add complex error handling for unlikely scenarios** - Simple error handling for expected cases only16- **Suggest design patterns unless actually required** - Use existing patterns, don't introduce new ones17- **Optimize prematurely** - Focus on correctness first, optimize only when performance issues are proven18- **Add configuration for rarely changing values** - Hard-code values that don't need to be configurable19- **Create duplicate functionality** - Always search for and reuse existing utilities20- **Write speculative code** - Each function should have a single, clear purpose tied to actual requirements2122## Project Overview2324Stock Options Tracker - An Astro-based web application for tracking and analyzing stock options with multi-factor scoring, historical performance tracking, and automated background data refresh via Cloudflare Workers.2526## Tech Stack2728- **Framework**: Astro 5.0.2 with server-side rendering29- **Styling**: Tailwind CSS (via @astrojs/tailwind)30- **Database**: Cloudflare D1 (SQLite)31- **Background Jobs**: Cloudflare Workers with cron scheduling32- **Data Sources**: Yahoo Finance 2, Finnhub API33- **Deployment**: Cloudflare Pages3435## Development Commands3637```bash38# Start development server (localhost:4321)39npm run dev4041# Build for production (includes type checking)42npm run build4344# Run linting and type checking45npm run all4647# Database migrations48npm run db:migrate # Local D1 database49npm run db:migrate:prod # Production database5051# Background worker52npm run worker:dev # Run worker locally53npm run worker:deploy # Deploy to development54npm run worker:deploy:prod # Deploy to production55```5657## Architecture5859### Data Flow601. User searches trigger data fetch from Yahoo Finance612. Results cached in D1 database with scoring calculation623. Background worker refreshes cached data every ~15 minutes during market hours634. UI reads from cache (fast <500ms responses)6465### Key Services6667**src/services/optionsService.ts**68- Fetches options data from Yahoo Finance69- Manages caching strategy70- Coordinates with database service7172**src/services/database_service.ts**73- All D1 database operations74- Snapshot creation and retrieval75- Symbol tracking management7677**src/workers/background_refresh.ts**78- Runs every minute (cron: `* * * * *`)79- Round-robin refresh of tracked symbols80- Market hours check (9:30 AM - 4:00 PM ET, weekdays)8182### Database Schema8384Key tables:85- `stock_snapshots` - Current stock prices86- `option_snapshots` - Individual option data87- `option_score_snapshots` - Calculated scores88- `symbol_tracking` - Symbols for background refresh8990View: `option_data_with_scores` joins all data for display9192### Options Scoring Algorithm9394Multi-factor scoring in `src/utils/optionScorer.ts`:95- Premium, Theta, Strike, DTE, IV, Liquidity scores96- Spread penalty for bid-ask spreads97- Results in score classes: excellent, good, moderate, weak, poor9899## API Endpoints100101All endpoints are server-side rendered Astro pages:102- `GET /api/stock-options?symbol=AAPL`103- `GET /api/historical-snapshots?symbol=AAPL`104- `GET /api/top-performing-options?symbol=AAPL&days=30`105- `GET /api/stock-performance?symbol=AAPL&days=30`106- `POST /api/refresh-status` (requires auth)107108## Component Structure109110Astro components with scoped CSS:111- `src/components/OptionsTable.astro` - Main options display112- `src/components/optionRow.astro` - Individual option rendering113- `src/components/historical_data_view.astro` - Historical trends114115Use Tailwind utilities directly in components. Avoid @apply directive.116117## Development Guidelines118119### Astro Best Practices120- Prioritize static generation where possible121- Use partial hydration sparingly (client:idle, client:visible)122- Keep components in `.astro` format when no client JS needed123- Scoped styles within components124125### TypeScript126- Strict type checking enabled127- Interfaces defined in `src/types/`128- Use proper null checking and error handling129130### Database Operations131- Always use database_service.ts methods132- Never expose database IDs in API responses133- Cache-first approach for all reads134135### Testing Single Features136```bash137# Test specific API endpoint138curl http://localhost:4321/api/stock-options?symbol=AAPL139140# Check worker execution141npm run worker:dev142# Then trigger manually via Wrangler dashboard143144# View D1 data145npx wrangler d1 execute options-tracker-local --local --command "SELECT * FROM symbol_tracking"146```147148## Environment Setup149150Required `.env` file:151```152PUBLIC_FINNHUB_API_KEY=your_key_here153```154155Local D1 database binding in `astro.config.mjs`:156- Database: `options-tracker-local`157- Auto-created on first run158159## Preferred Stocks160161Hardcoded list in `src/enums/preferredStocks.ts`:162TSLA, NET, LRCX, CRWD, NVDA, SE, KKR, BX, AAPL, GOOGL, META, AMD, AMZN, NFLX, MSFT163164These receive priority 10 in background refresh (vs priority 5 for user-searched).165166## Common Modifications167168### Add New Preferred Stock1691. Update `src/enums/preferredStocks.ts`1702. Symbol automatically added to tracking on next page load171172### Adjust Scoring Algorithm1731. Modify weights in `src/utils/optionScorer.ts`1742. Update thresholds in `src/enums/scoreThresholds.ts`175176### Change Refresh Frequency1771. Edit cron schedule in `wrangler.background.toml`1782. Adjust round-robin logic in `background_refresh.ts` if needed179180### Add New API Endpoint1811. Create new file in `src/pages/api/`1822. Export async GET/POST handler1833. Use database_service.ts for data access184185## Deployment Notes186187Production uses Cloudflare Pages with Workers:188- Main app deploys automatically via GitHub189- Worker requires manual deployment: `npm run worker:deploy:prod`190- Database migrations must be run separately: `npm run db:migrate:prod`191192Monitor worker execution in Cloudflare dashboard under Workers > Logs.
Also in sferg989/fergfo.om
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 |
|---|---|---|---|---|---|
| sferg989/fergfo.om.cursor/rules/astro-component-structure.mdc · 0 | Cursor rules | stylearchui | 58/100 | 3 days ago | |
| sferg989/fergfo.om.cursor/rules/astro-database-integration.mdc · 0 | Cursor rules | database | 50/100 | 3 days ago | |
| sferg989/fergfo.om.cursor/rules/astro-error-handling.mdc · 0 | Cursor rules | styledatabaseui | 58/100 | 3 days ago | |
| sferg989/fergfo.om.cursor/rules/astro-performance-patterns.mdc · 0 | Cursor rules | buildstyledatabaseperformance | 62/100 | 3 days ago | |
| sferg989/fergfo.om.cursor/rules/astro-ssr-patterns.mdc · 0 | Cursor rules | style | 49/100 | 3 days ago | |
| sferg989/fergfo.om.cursor/rules/ts-typecheck.mdc · 0 | Cursor rules | do-not | 23/100 | 3 days ago | |
| sferg989/fergfo.om.cursor/rules/ts.mdc · 0 | Cursor rules | styletypesdo-notdocs | 55/100 | 3 days ago | |
| sferg989/fergfo.om.cursorrules · 0 | .cursorrules | do-not | 49/100 | 3 days ago |
Diff against .cursor/rules/astro-component-structure.mdc Diff against .cursor/rules/astro-database-integration.mdc Diff against .cursor/rules/astro-error-handling.mdc Diff against .cursor/rules/astro-performance-patterns.mdc Diff against .cursor/rules/astro-ssr-patterns.mdc Diff against .cursor/rules/ts-typecheck.mdc Diff against .cursor/rules/ts.mdc Diff against .cursorrules
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| Adit-Jain-srm/NightmareNetCLAUDE.md · 45 | CLAUDE.md | buildtestlint-formatstyle+6 | 100/100 | 3 days ago | |
| bagisto/bagistoCLAUDE.md · 28k | CLAUDE.md | setupbuildteststyle+5 | 100/100 | 3 days ago | |
| microsoft/playwrightCLAUDE.md · 94k | CLAUDE.md | buildtestlint-formatstyle+7 | 100/100 | 3 days ago | |
| dotCMS/corecore-web/CLAUDE.md · 949 | CLAUDE.md | teststylearchtesting-strategy+3 | 100/100 | 3 days ago | |
| nimbalyst/nimbalystpackages/android/CLAUDE.md · 1.4k | CLAUDE.md | setupbuildstylearch+2 | 100/100 | 3 days ago | |
| filamentphp/filamentCLAUDE.md · 32k | CLAUDE.md | buildtestlint-formatstyle+7 | 100/100 | 3 days ago | |
| dotCMS/coreCLAUDE.md · 949 | CLAUDE.md | setupbuildteststyle+7 | 99/100 | today | |
| lollipopkit/flutter_server_boxCLAUDE.md · 8.3k | CLAUDE.md | buildteststylearch+2 | 98/100 | 3 days ago |
