CLAUDE.md
Documents a SvelteKit OWASP risk calculator's architecture, domain model, and development commands for Claude Code.
What this file does
Documents a SvelteKit OWASP risk calculator's architecture, domain model, and development commands for Claude Code.
When to use it
- Onboarding a new developer to the OWASP risk calculator codebase
- Setting up Claude Code to assist with this SvelteKit project
- Understanding the risk calculation flow and factor set builders
- Learning the mitigation feature and radar chart integration
Assumes this stack
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
This is an OWASP Risk Rating Calculator built with SvelteKit that implements the OWASP Risk Rating Methodology. It calculates security risk severity based on likelihood and impact factors, with support for mitigation tracking displayed via radar charts.
Development Commands
# Install dependencies (uses pnpm)
pnpm install
# Start development server
pnpm dev
# Or open in browser automatically
pnpm dev -- --open
# Type checking
pnpm check
# Type checking in watch mode
pnpm check:watch
# Linting and formatting
pnpm lint # Check formatting with Prettier and lint with ESLint
pnpm format # Auto-format with Prettier
# Production build
pnpm build
# Preview production build
pnpm preview
Architecture
Core Domain Model
The application is built around a hierarchical risk assessment model:
-
Risk (
src/lib/risk/Risk.ts): Top-level entity representing a security risk- Contains
likelihoodFactorSetsandimpactFactorSetsarrays - Each Risk can have an optional
mitigationproperty (also a Risk instance) - Likelihood is calculated as the average of all likelihood factor sets
- Impact follows OWASP methodology: Business Impact takes priority over Technical Impact if present (score > 0)
- Contains
-
FactorSet (
src/lib/risk/FactorSet.ts): Groups related factors together- Examples: Threat Agent Factors, Vulnerability Factors, Technical Impact, Business Impact
- Implements
IScoreSource- calculates score as average of contained factors - Defined via builder pattern (see
src/lib/risk/constants/)
-
Factor (
src/lib/risk/Factor.ts): Individual risk assessment criteria- Contains a numeric score (0-9) and options for dropdown selection
- Each option maps a score to a descriptive label
- Colors for visualization are defined in
FactorColorMap
Risk Calculation Flow
- Likelihood: Average of Threat Agent Factors and Vulnerability Factors
- Impact: Business Impact if present (score > 0), otherwise Technical Impact
- Severity: Determined by
RiskSeverityMatrix(src/lib/risk/RiskSeverity.ts) which maps likelihood and impact levels to severity (Note/Low/Medium/High/Critical)
State Management
Uses Svelte stores (src/lib/risk/Store.ts):
risks: Array of all risk assessmentseditRisk: Currently selected risk for editing (triggers modal)deleteRisk: Risk selected for deletion (triggers confirmation modal)
UI Component Structure
- Risk.svelte: Main risk display with tabs for risk/mitigation views and radar chart
- RiskForm.svelte: Form for editing risk factors (used for both risk and mitigation)
- FactorSet.svelte and Factor.svelte: Render factor groups and individual factors
- Radar.svelte: Chart.js radar visualization comparing risk vs mitigation
- Action components in
src/lib/components/actions/: AddRisk, EditRisk, DeleteRisk, ClearRisks (handle modals)
Factor Set Builders
Located in src/lib/risk/constants/:
likelihoodFactorSet.ts: Threat Agent Factors (Skill Level, Motive, Opportunity, Size)vulnerabilityFactorSet.ts: Vulnerability Factors (Ease of Discovery, Ease of Exploit, Awareness, Intrusion Detection)techImpactFactorSet.ts: Technical Impact (Loss of Confidentiality, Integrity, Availability, Accountability)businessImpactFactorSet.ts: Business Impact (Financial Damage, Reputation Damage, Non-Compliance, Privacy Violation)
Each builder implements IFactorSetBuilder and constructs a FactorSet with predefined factors following OWASP methodology.
Mitigation Feature
- Each Risk can have a mitigation Risk attached (
risk.mitigation) - When creating mitigation, factor scores are copied from the parent risk using
Risk.copyFactorScores() - Users then adjust mitigation scores to reflect reduced risk after controls
- Radar chart overlays both datasets for visual comparison
Build Configuration
- Vite with SvelteKit plugin
- Base path:
/owasp-risk-calculator(configured invite.config.ts) - Adapter: Static adapter (
@sveltejs/adapter-static) for static site generation - Preprocessors: Tailwind CSS via PostCSS, SASS support
- UI Framework: Flowbite Svelte components with Tailwind CSS
Key Dependencies
- SvelteKit 2.x: Application framework
- Svelte 4.x: Component framework
- Chart.js + svelte-chartjs: Radar chart visualization
- Flowbite Svelte: UI component library
- TypeScript 5.x: Type safety
What's inside
6 sections: overview, commands, architecture, build config, dependencies, plus code snippets and diagrams
Change this for your project
- Replace
owasp-risk-calculatorin base path with your own repo name - Replace
src/lib/risk/paths with your own domain model location - Replace
pnpmcommands with npm or yarn if not using pnpm
Where it goes
Save as CLAUDE.md in your repository root. Claude Code reads it automatically at the start of every session.
Worth borrowing
- Using a builder pattern (IFactorSetBuilder) to construct domain objects with predefined factors
- Copying factor scores from parent risk to mitigation for before/after comparison
Related Documents
Code indexing for AI agents: summarization strategies and evaluation systems
Synthesises 2024-2025 research on code indexing for AI agents, covering summarisation strategies, hybrid retrieval architectures, and evaluation benchmarks.
write-script
Guides an AI through writing a YouTube video script with strict structural, language, and quiz rules for a survival channel.
Claude AI Git Workflow Integration
Recommends using the git-ai-commit CLI tool for AI-generated commit messages instead of manual ones.
Missing Business Agents Research — FLUXION 2026
Identifies 12 missing business operations agents for an indie software company and ranks them by impact and effort with €0 implementation plans.