Skip to content

πŸͺ’ Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

chore: Replace Claude hook setup with agent instructions (#12470)

Max Deichmann393dab716413
diff --git a/.agents/skills/README.md b/.agents/skills/README.md
new file mode 100644
index 0000000000..e48fc1474b
--- /dev/null
+++ b/.agents/skills/README.md
@@ -0,0 +1,52 @@
+# Shared Skills
+
+Shared repo skills for any coding agent working in Langfuse.
+
+Use these from `AGENTS.md` and `CLAUDE.md`. They are not tool-specific and
+should stay focused on reusable implementation guidance rather than runtime
+automation.
+
+Shared skills should use progressive disclosure:
+
+- `SKILL.md` is the short entrypoint with trigger guidance and navigation.
+- `AGENTS.md` is optional and should stay concise when it exists.
+- `references/` holds focused prose references that agents should open only
+ when the task needs them.
+- `scripts/` holds deterministic helpers for repetitive or fragile steps.
+
+## Available Skills
+
+### backend-dev-guidelines
+
+Use for:
+- tRPC routers and procedures
+- public API endpoints
+- worker queue processors
+- Prisma and ClickHouse backed services
+- backend auth, validation, observability, and tests
+
+Open: [backend-dev-guidelines/SKILL.md](backend-dev-guidelines/SKILL.md)
+
+### add-model-price
+
+Use for:
+- `worker/src/constants/default-model-prices.json`
+- `packages/shared/src/server/llm/types.ts`
+- pricing tiers, tokenizer IDs, and model `matchPattern` changes
+
+Open: [add-model-price/SKILL.md](add-model-price/SKILL.md)
+
+## Adding a New Shared Skill
+
+1. Codex may create or refine shared skills under `.agents/skills/` when a
+ repo-specific workflow becomes repeated enough to justify durable guidance.
+2. Create a concise `.agents/skills/<skill-name>/SKILL.md`.
+3. Add `.agents/skills/<skill-name>/AGENTS.md` only when the skill benefits
+ from a short router or checklist on top of `SKILL.md`.
+4. Prefer `references/` for detailed prose and `scripts/` for deterministic
+ execution helpers.
+5. Keep the skill tightly scoped to one domain or workflow.
+6. Link the skill from `AGENTS.md` if it is relevant across the repo.
+7. Link the skill from `CLAUDE.md` if Claude Code should load it from the
+ project entrypoint.
+8. Run `pnpm run skills:check` after editing any skill files.
diff --git a/.agents/skills/add-model-price/AGENTS.md b/.agents/skills/add-model-price/AGENTS.md
new file mode 100644
index 0000000000..658edcd696
--- /dev/null
+++ b/.agents/skills/add-model-price/AGENTS.md
@@ -0,0 +1,544 @@
+# Add Model Price
+
+Guide for adding or updating model pricing entries in Langfuse. Use this when
+editing `worker/src/constants/default-model-prices.json`,
+`packages/shared/src/server/llm/types.ts`, model `matchPattern` values,
+tokenizer IDs, or pricing tiers.
+
+## Purpose
+
+This guide keeps model pricing changes consistent across providers and runtime
+surfaces so Langfuse can calculate token costs accurately.
+
+## How to Use This Skill
+
+1. Read [references/schema-and-tiers.md](references/schema-and-tiers.md) for
+ the JSON shape and pricing-tier rules.
+2. Read
+ [references/provider-sources-and-price-keys.md](references/provider-sources-and-price-keys.md)
+ for official pricing URLs, per-token conversion, and provider-specific usage
+ keys.
+3. Read [references/match-patterns.md](references/match-patterns.md) when you
+ need to add or expand regex coverage.
+4. Read
+ [references/workflow-and-validation.md](references/workflow-and-validation.md)
+ for the end-to-end edit workflow, validation rules, and common mistakes.
+
+## Deterministic Helpers
+
+- Validate the pricing file:
+ `node .agents/skills/add-model-price/scripts/validate-pricing-file.mjs`
+- Test a regex directly:
+ `node .agents/skills/add-model-price/scripts/test-match-pattern.mjs --pattern '(?i)^(openai/)?(gpt-4o)$' --accept gpt-4o openai/gpt-4o --reject gpt-4o-mini`
+- Test the regex for an existing model entry:
+ `node .agents/skills/add-model-price/scripts/test-match-pattern.mjs --model gpt-4o --accept gpt-4o openai/gpt-4o --reject gpt-4o-mini`
+
+## Quick Start Checklist
+
+### Adding a New Model
+
+- [ ] Gather official pricing from the provider documentation
+- [ ] Generate a lowercase UUID for the model entry
+- [ ] Create a `matchPattern` that covers supported provider formats
+- [ ] Add at least one default pricing tier
+- [ ] Insert the pricing entry into
+ `worker/src/constants/default-model-prices.json`
+- [ ] Update `packages/shared/src/server/llm/types.ts` if the model should be
+ selectable in playground or evaluation flows
+- [ ] Validate the JSON after editing
+
+### Updating an Existing Model
+
+- [ ] Update the relevant prices, keys, tiers, or regexes
+- [ ] Refresh `updatedAt` to today's ISO-8601 timestamp
+- [ ] Validate the JSON after editing
+
+## Target Files
+
+- Pricing data:
+ `worker/src/constants/default-model-prices.json`
+- Shared model types:
+ `packages/shared/src/server/llm/types.ts`
+- Validation logic:
+ `packages/shared/src/features/model-pricing/validation.ts`
+- Matching logic:
+ `packages/shared/src/server/pricing-tiers/matcher.ts`
+- Tests:
+ `worker/src/__tests__/pricing-tier-matcher.test.ts`
+
+## Data Structure
+
+### Complete Model Entry Schema
+
+```json
+{
+ "id": "uuid-generated-with-uuidgen",
+ "modelName": "model-name-identifier",
+ "matchPattern": "(?i)^regex-pattern$",
+ "createdAt": "ISO-8601-timestamp",
+ "updatedAt": "ISO-8601-timestamp",
+ "tokenizerConfig": null,
+ "tokenizerId": "claude|openai|null",
+ "pricingTiers": [
+ {
+ "id": "model-uuid_tier_default",
+ "name": "Standard",
+ "isDefault": true,
+ "priority": 0,
+ "conditions": [],
+ "prices": {
+ "input": 0.000005,
+ "output": 0.000025
+ }
+ }
+ ]
+}
+```
+
+### Required Fields
+
+| Field | Type | Description |
+| --- | --- | --- |
+| `id` | string | Unique lowercase UUID |
+| `modelName` | string | Primary model identifier |
+| `matchPattern` | string | Regex for matching model names |
+| `createdAt` | string | ISO-8601 timestamp set on creation |
+| `updatedAt` | string | ISO-8601 timestamp refreshed whenever the entry changes |
+| `pricingTiers` | array | At least one pricing tier |
+
+### Optional Fields
+
+| Field | Type | Default | Description |
+| --- | --- | --- | --- |
+| `tokenizerId` | string | `null` | `"claude"`, `"openai"`, or `null` |
+| `tokenizerConfig` | object | `null` | Custom tokenizer settings |
+
+## Pricing Tier Structure
+
+### Default Tier
+
+Every model must have exactly one default tier:
+
+```json
+{
+ "id": "{model-id}_tier_default",
+ "name": "Standard",
+ "isDefault": true,
+ "priority": 0,
+ "conditions": [],
+ "prices": {}
+}
+```
+
+Rules for the default tier:
+
+- `isDefault` must be `true`
+- `priority` must be `0`
+- `conditions` must be `[]`
+
+### Additional Tiers
+
+Use extra tiers for context-window or usage-based pricing:
+
+```json
+{
+ "id": "uuid-for-tier",
+ "name": "Large Context (>200K)",
+ "isDefault": false,
+ "priority": 1,
+ "conditions": [
+ {
+ "usageDetailPattern": "(input|prompt|cached)",
+ "operator": "gt",
+ "value": 200000,
+ "caseSensitive": false
+ }
+ ],
+ "prices": {}
+}
+```
+
+Supported condition operators: `gt`, `gte`, `lt`, `lte`, `eq`, `neq`
+
+## Official Pricing Sources
+
+Always fetch pricing from the provider's official docs before editing. Do not
+infer or estimate missing values.
+
+| Provider | Source |
+| --- | --- |
+| Anthropic Claude | `https://platform.claude.com/docs/en/about-claude/pricing` |
+| OpenAI | `https://openai.com/api/pricing/` |
+| Google Gemini | `https://ai.google.dev/pricing` |
+| AWS Bedrock | `https://aws.amazon.com/bedrock/pricing/` |
+| Azure OpenAI | `https://azure.microsoft.com/pricing/details/cognitive-services/openai-service/` |
+
+Gather:
+
+1. Base input token price per million tokens
+2. Output token price per million tokens
+3. Cache write price when supported
+4. Cache read price when supported
+5. Any long-context pricing tiers
+6. All model ID formats that Langfuse should match
+
+## Price Conversion
+
+Values in `default-model-prices.json` are per token, not per million tokens.
+
+| Provider Price | JSON Value |
+| --- | --- |
+| `$5 / MTok` | `5e-6` |
+| `$25 / MTok` | `25e-6` |
+| `$0.50 / MTok` | `0.5e-6` |
+| `$6.25 / MTok` | `6.25e-6` |
+
+Formula:
+
+```text
+price_per_token = price_per_mtok / 1_000_000
+```
+
+## Common Price Keys by Provider
+
+### Anthropic Claude Models
+
+```json
+{
+ "input": "<base_input_price>",
+ "input_tokens": "<base_input_price>",
+ "output": "<output_price>",
+ "output_tokens": "<output_price>",
+ "cache_creation_input_tokens": "<cache_write_price>",
+ "input_cache_creation": "<cache_write_price>",
+ "cache_read_input_tokens": "<cache_read_price>",
+ "input_cache_read": "<cache_read_price>"
+}
+```
+
+### OpenAI Models
+
+```json
+{
+ "input": "<input_price>",
+ "input_cached_tokens": "<cached_input_price>",
+ "input_cache_read": "<cached_input_price>",
+ "output": "<output_price>"
+}
+```
+
+### Google Gemini Models
+
+```json
+{
+ "input": "<input_price>",
+ "input_modality_1": "<input_price>",
+ "prompt_token_count": "<input_price>",
+ "promptTokenCount": "<input_price>",
+ "input_cached_tokens": "<cached_price>",
+ "cached_content_token_count": "<cached_price>",
+ "output": "<output_price>",
+ "output_modality_1": "<output_price>",
+ "candidates_token_count": "<output_price>",
+ "candidatesTokenCount": "<output_price>"
+}
+```
+
+## Match Pattern Examples
+
+### Anthropic Claude: API + Bedrock + Vertex
+
+```regex
+(?i)^(anthropic\/)?(claude-opus-4-6|(eu\\.|us\\.|apac\\.)?anthropic\\.claude-opus-4-6-v1(:0)?|claude-opus-4-6)$
+```
+
+Matches:
+
+- `claude-opus-4-6`
+- `anthropic/claude-opus-4-6`
+- `anthropic.claude-opus-4-6-v1:0`
+- `us.anthropic.claude-opus-4-6-v1:0`
+- `claude-opus-4-6`
+
+### With Version Date
+
+```regex
+(?i)^(anthropic\/)?(claude-opus-4-5-20251101|(eu\\.|us\\.|apac\\.)?anthropic\\.claude-opus-4-5-20251101-v1:0|claude-opus-4-5@20251101)$
+```
+
+### OpenAI
+
+```regex
+(?i)^(openai\/)?(gpt-4o)$
+```
+
+### Google Gemini
+
+```regex
+(?i)^(google\/)?(gemini-2.5-pro)$
+```
+
+### Pattern Components
+
+| Component | Purpose | Example |
+| --- | --- | --- |
+| `(?i)` | Case-insensitive match | `gpt-4o` and `GPT-4O` |
+| `^...$` | Full-string match | Avoids partial matches |
+| `(provider\/)?` | Optional provider prefix | `openai/gpt-4o` |
+| `(eu\\.|us\\.|apac\\.)?` | Optional AWS region prefix | `us.anthropic.model` |
+| `(:0)?` | Optional version suffix | Bedrock model versions |
+| `@date` | Vertex AI version format | `claude-3-5-sonnet@20240620` |
+
+## Step-by-Step Workflow
+
+### 1. Fetch Official Pricing
+
+Open the official provider pricing page and capture the model's input, output,
+cache write, and cache read prices.
+
+### 2. Generate a Lowercase UUID
+
+```bash
+uuidgen
+```
+
+Convert the output to lowercase before using it.
+
+### 3. Create the JSON Entry
+
+Example for a model with $5 input, $25 output, $6.25 cache write, and
+$0.50 cache read:
+
+```json
+{
+ "id": "13458bc0-1c20-44c2-8753-172f54b67647",
+ "modelName": "claude-opus-4-6",
+ "matchPattern": "(?i)^(anthropic\/)?(claude-opus-4-6|(eu\\.|us\\.|apac\\.)?anthropic\\.claude-opus-4-6-v1(:0)?|claude-opus-4-6)$",
+ "createdAt": "2026-03-09T00:00:00.000Z",
+ "updatedAt": "2026-03-09T00:00:00.000Z",
+ "tokenizerConfig": null,
+ "tokenizerId": "claude",
+ "pricingTiers": [
+ {
+ "id": "13458bc0-1c20-44c2-8753-172f54b67647_tier_default",
+ "name": "Standard",
+ "isDefault": true,
+ "priority": 0,
+ "conditions": [],
+ "prices": {
+ "input": 5e-6,
+ "input_tokens": 5e-6,
+ "output": 25e-6,
+ "output_tokens": 25e-6,
+ "cache_creation_input_tokens": 6.25e-6,
+ "input_cache_creation": 6.25e-6,
+ "cache_read_input_tokens": 0.5e-6,
+ "input_cache_read": 0.5e-6
+ }
+ }
+ ]
+}
+```
+
+### 4. Insert the Entry
+
+Add the entry to the JSON array in
+`worker/src/constants/default-model-prices.json`. Keep related models grouped
+together.
+
+### 5. Update Shared Model Types When Needed
+
+If the model should be available in the playground or LLM-as-judge flows, add
+it to the correct array in `packages/shared/src/server/llm/types.ts`.
+
+Model arrays include:
+
+- `anthropicModels`
+- `openAIModels`
+- `vertexAIModels`
+- `googleAIStudioModels`
+
+Do not add a new model as the first entry in one of these arrays. The first
+entry is used as a default model in some test or evaluation paths and newer
+models may not be available to all users yet.
+
+### 6. Validate the Change
+
+```bash
+jq . worker/src/constants/default-model-prices.json > /dev/null
+```
+
+You can also inspect a specific entry:
+
+```bash
+jq '.[] | select(.modelName == "claude-opus-4-6")' worker/src/constants/default-model-prices.json
+```
+
+## Multi-Tier Example
+
+For models with long-context pricing:
+
+```json
+{
+ "id": "uuid-here",
+ "modelName": "model-name",
+ "matchPattern": "...",
+ "pricingTiers": [
+ {
+ "id": "uuid-here_tier_default",
+ "name": "Standard",
+ "isDefault": true,
+ "priority": 0,
+ "conditions": [],
+ "prices": {
+ "input": 5e-6,
+ "output": 25e-6
+ }
+ },
+ {
+ "id": "uuid-for-large-context-tier",
+ "name": "Large Context (>200K)",
+ "isDefault": false,
+ "priority": 1,
+ "conditions": [
+ {
+ "usageDetailPattern": "(input|prompt|cached)",
+ "operator": "gt",
+ "value": 200000,
+ "caseSensitive": false
+ }
+ ],
+ "prices": {
+ "input": 10e-6,
+ "output": 37.5e-6
+ }
+ }
+ ]
+}
+```
+
+## Validation Rules
+
+1. Exactly one default tier must have `isDefault: true`
+2. The default tier must have `priority: 0`
+3. The default tier must have `conditions: []`
+4. Non-default tiers must have `priority > 0`
+5. Non-default tiers must have at least one condition
+6. Priorities must be unique within a model
+7. Tier names must be unique within a model
+8. Each tier must contain at least one price
+9. All tiers must expose the same usage-type keys
+10. Regex patterns must be valid and safe
+
+## Common Mistakes
+
+### Guessing Instead of Using Official Pricing
+
+Wrong:
+
+```json
+{
+ "cache_creation_input_tokens": "input_price * 1.25"
+}
+```
+
+Correct:
+
+```json
+{
+ "cache_creation_input_tokens": 6.25e-6
+}
+```
+
+### Using MTok Values Directly
+
+Wrong:
+
+```json
+{
+ "input": 5
+}
+```
+
+Correct:
+
+```json
+{
+ "input": 5e-6
+}
+```
+
+### Missing the Default Tier Suffix
+
+Wrong:
+
+```json
+{
+ "id": "some-uuid"
+}
+```
+
+Correct:
+
+```json
+{
+ "id": "model-uuid_tier_default"
+}
+```
+
+### Invalid Regex Escaping
+
+Wrong:
+
+```json
+{
+ "matchPattern": "anthropic.claude"
+}
+```
+
+Correct:
+
+```json
+{
+ "matchPattern": "anthropic\\.claude"
+}
+```
+
+### Forgetting to Update `updatedAt`
+
+Wrong:
+
+```json
+{
+ "updatedAt": "2025-12-12T15:00:06.513Z"
+}
+```
+
+Correct:
+
+```json
+{
+ "updatedAt": "2026-03-09T00:00:00.000Z"
+}
+```
+
+## Testing Model Matching
+
+After adding a model, verify that the regex matches the intended provider
+variants:
+
+```javascript
+const pattern = new RegExp(matchPattern);
+console.log(pattern.test("claude-opus-4-6")); // true
+console.log(pattern.test("anthropic/claude-opus-4-6")); // true
+console.log(pattern.test("anthropic.claude-opus-4-6-v1:0")); // true
+console.log(pattern.test("us.anthropic.claude-opus-4-6-v1:0")); // true
+```
+
+## Existing Model Templates
+
+Use nearby entries as templates:
+
+- `claude-opus-4-5-20251101` for Anthropic multi-provider patterns
+- `gpt-4o` for a simple OpenAI pattern
+- `gemini-2.5-pro` for a multi-tier Gemini entry
diff --git a/.agents/skills/add-model-price/SKILL.md b/.agents/skills/add-model-price/SKILL.md
new file mode 100644
index 0000000000..091cda3163
--- /dev/null
+++ b/.agents/skills/add-model-price/SKILL.md
@@ -0,0 +1,40 @@
+---
+name: add-model-price
+description: Use when editing worker/src/constants/default-model-prices.json, packages/shared/src/server/llm/types.ts, pricing tiers, tokenizer IDs, or matchPattern regexes for OpenAI, Anthropic, Bedrock, Vertex, Azure, or Gemini model pricing.
+---
+
+# Add Model Price
+
+Use this skill for model pricing changes in `worker/` and shared LLM type
+updates in `packages/shared/`.
+
+## When to Apply
+
+- Editing `worker/src/constants/default-model-prices.json`
+- Editing `packages/shared/src/server/llm/types.ts`
+- Adding a new priced model
+- Updating provider prices, cache pricing, or tier conditions
+- Expanding regex coverage for Bedrock, Vertex, Azure, or provider-prefixed
+ model names
+
+## How to Read This Skill
+
+- Start with [AGENTS.md](AGENTS.md) for the high-level workflow and helper
+ scripts.
+- Then open only the specific reference file that matches the task.
+
+## Reference Map
+
+| Topic | Read this when | File |
+| --- | --- | --- |
+| Schema and tier rules | You need the entry shape or pricing-tier invariants | [references/schema-and-tiers.md](references/schema-and-tiers.md) |
+| Provider sources and price keys | You need official pricing URLs, per-token conversion, or provider-specific usage keys | [references/provider-sources-and-price-keys.md](references/provider-sources-and-price-keys.md) |
+| Match patterns | You are editing `matchPattern` regexes or provider coverage | [references/match-patterns.md](references/match-patterns.md) |
+| Workflow and validation | You are applying the end-to-end edit process or checking common mistakes | [references/workflow-and-validation.md](references/workflow-and-validation.md) |
+
+## Deterministic Helpers
+
+- Pricing file validator:
+ `node .agents/skills/add-model-price/scripts/validate-pricing-file.mjs`
+- Match-pattern tester:
+ `node .agents/skills/add-model-price/scripts/test-match-pattern.mjs --model <modelName> --accept <sample...> --reject <sample...>`
diff --git a/.agents/skills/add-model-price/references/match-patterns.md b/.agents/skills/add-model-price/references/match-patterns.md
new file mode 100644
index 0000000000..7863c8ac4a
--- /dev/null
+++ b/.agents/skills/add-model-price/references/match-patterns.md
@@ -0,0 +1,51 @@
+# Match Patterns
+
+## Anthropic Claude: API + Bedrock + Vertex
+
+```regex
+(?i)^(anthropic\/)?(claude-opus-4-6|(eu\\.|us\\.|apac\\.)?anthropic\\.claude-opus-4-6-v1(:0)?|claude-opus-4-6)$
+```
+
+Matches:
+
+- `claude-opus-4-6`
+- `anthropic/claude-opus-4-6`
+- `anthropic.claude-opus-4-6-v1:0`
+- `us.anthropic.claude-opus-4-6-v1:0`
+
+## With Version Date
+
+```regex
+(?i)^(anthropic\/)?(claude-opus-4-5-20251101|(eu\\.|us\\.|apac\\.)?anthropic\\.claude-opus-4-5-20251101-v1:0|claude-opus-4-5@20251101)$
+```
+
+## OpenAI
+
+```regex
+(?i)^(openai\/)?(gpt-4o)$
+```
+
+## Google Gemini
+
+```regex
+(?i)^(google\/)?(gemini-2.5-pro)$
+```
+
+## Pattern Components
+
+| Component | Purpose | Example |
+| --- | --- | --- |
+| `(?i)` | Case-insensitive match | `gpt-4o` and `GPT-4O` |
+| `^...$` | Full-string match | Avoids partial matches |
+| `(provider\/)?` | Optional provider prefix | `openai/gpt-4o` |
+| `(eu\\.|us\\.|apac\\.)?` | Optional AWS region prefix | `us.anthropic.model` |
+| `(:0)?` | Optional version suffix | Bedrock model versions |
+| `@date` | Vertex AI version format | `claude-3-5-sonnet@20240620` |
+
+## Testing Patterns
+
+Use the bundled helper script:
+
+```bash
+node .agents/skills/add-model-price/scripts/test-match-pattern.mjs --model gpt-4o --accept gpt-4o openai/gpt-4o --reject gpt-4o-mini
+```
diff --git a/.agents/skills/add-model-price/references/provider-sources-and-price-keys.md b/.agents/skills/add-model-price/references/provider-sources-and-price-keys.md
new file mode 100644
index 0000000000..fc9d4da87a
--- /dev/null
+++ b/.agents/skills/add-model-price/references/provider-sources-and-price-keys.md
@@ -0,0 +1,84 @@
+# Provider Sources and Price Keys
+
+## Official Pricing Sources
+
+Always fetch pricing from the provider's official docs before editing.
+
+| Provider | Source |
+| --- | --- |
+| Anthropic Claude | `https://platform.claude.com/docs/en/about-claude/pricing` |
+| OpenAI | `https://openai.com/api/pricing/` |
+| Google Gemini | `https://ai.google.dev/pricing` |
+| AWS Bedrock | `https://aws.amazon.com/bedrock/pricing/` |
+| Azure OpenAI | `https://azure.microsoft.com/pricing/details/cognitive-services/openai-service/` |
+
+Capture:
+
+1. Base input token price per million tokens
+2. Output token price per million tokens
+3. Cache write price when supported
+4. Cache read price when supported
+5. Any long-context or conditional pricing
+6. All model ID variants that Langfuse should match
+
+## Price Conversion
+
+Values in `default-model-prices.json` are per token, not per million tokens.
+
+| Provider Price | JSON Value |
+| --- | --- |
+| `$5 / MTok` | `5e-6` |
+| `$25 / MTok` | `25e-6` |
+| `$0.50 / MTok` | `0.5e-6` |
+| `$6.25 / MTok` | `6.25e-6` |
+
+Formula:
+
+```text
+price_per_token = price_per_mtok / 1_000_000
+```
+
+## Common Price Keys by Provider
+
+### Anthropic Claude
+
+```json
+{
+ "input": "<base_input_price>",
+ "input_tokens": "<base_input_price>",
+ "output": "<output_price>",
+ "output_tokens": "<output_price>",
+ "cache_creation_input_tokens": "<cache_write_price>",
+ "input_cache_creation": "<cache_write_price>",
+ "cache_read_input_tokens": "<cache_read_price>",
+ "input_cache_read": "<cache_read_price>"
+}
+```
+
+### OpenAI
+
+```json
+{
+ "input": "<input_price>",
+ "input_cached_tokens": "<cached_input_price>",
+ "input_cache_read": "<cached_input_price>",
+ "output": "<output_price>"
+}
+```
+
+### Google Gemini
+
+```json
+{
+ "input": "<input_price>",
+ "input_modality_1": "<input_price>",
+ "prompt_token_count": "<input_price>",
+ "promptTokenCount": "<input_price>",
+ "input_cached_tokens": "<cached_price>",
+ "cached_content_token_count": "<cached_price>",
+ "output": "<output_price>",
+ "output_modality_1": "<output_price>",
+ "candidates_token_count": "<output_price>",
+ "candidatesTokenCount": "<output_price>"
+}
+```
diff --git a/.agents/skills/add-model-price/references/schema-and-tiers.md b/.agents/skills/add-model-price/references/schema-and-tiers.md
new file mode 100644
index 0000000000..b4bb1ee182
--- /dev/null
+++ b/.agents/skills/add-model-price/references/schema-and-tiers.md
@@ -0,0 +1,96 @@
+# Schema and Tiers
+
+## Target Files
+
+- Pricing data: `worker/src/constants/default-model-prices.json`
+- Shared model types: `packages/shared/src/server/llm/types.ts`
+
+## Complete Model Entry Schema
+
+```json
+{
+ "id": "uuid-generated-with-uuidgen",
+ "modelName": "model-name-identifier",
+ "matchPattern": "(?i)^regex-pattern$",
+ "createdAt": "ISO-8601-timestamp",
+ "updatedAt": "ISO-8601-timestamp",
+ "tokenizerConfig": null,
+ "tokenizerId": "claude|openai|null",
+ "pricingTiers": [
+ {
+ "id": "model-uuid_tier_default",
+ "name": "Standard",
+ "isDefault": true,
+ "priority": 0,
+ "conditions": [],
+ "prices": {
+ "input": 0.000005,
+ "output": 0.000025
+ }
+ }
+ ]
+}
+```
+
+## Required Fields
+
+| Field | Type | Description |
+| --- | --- | --- |
+| `id` | string | Unique lowercase ID used by the pricing file |
+| `modelName` | string | Primary model identifier |
+| `matchPattern` | string | Regex used to match provider model names |
+| `createdAt` | string | ISO-8601 timestamp set on creation |
+| `updatedAt` | string | ISO-8601 timestamp refreshed whenever the entry changes |
+| `pricingTiers` | array | At least one pricing tier |
+
+## Optional Fields
+
+| Field | Type | Default | Description |
+| --- | --- | --- | --- |
+| `tokenizerId` | string | `null` | Usually `"claude"`, `"openai"`, or `null` |
+| `tokenizerConfig` | object | `null` | Custom tokenizer settings |
+
+## Default Tier
+
+Every model must have exactly one default tier:
+
+```json
+{
+ "id": "{model-id}_tier_default",
+ "name": "Standard",
+ "isDefault": true,
+ "priority": 0,
+ "conditions": [],
+ "prices": {}
+}
+```
+
+Rules:
+
+- `isDefault` must be `true`
+- `priority` must be `0`
+- `conditions` must be `[]`
+
+## Additional Tiers
+
+Use extra tiers for context-window or usage-based pricing:
+
+```json
+{
+ "id": "uuid-for-tier",
+ "name": "Large Context (>200K)",
+ "isDefault": false,
+ "priority": 1,
+ "conditions": [
+ {
+ "usageDetailPattern": "(input|prompt|cached)",
+ "operator": "gt",
+ "value": 200000,
+ "caseSensitive": false
+ }
+ ],
+ "prices": {}
+}
+```
+
+Supported operators: `gt`, `gte`, `lt`, `lte`, `eq`, `neq`
diff --git a/.agents/skills/add-model-price/references/workflow-and-validation.md b/.agents/skills/add-model-price/references/workflow-and-validation.md
new file mode 100644
index 0000000000..735dcbf05c
--- /dev/null
+++ b/.agents/skills/add-model-price/references/workflow-and-validation.md
@@ -0,0 +1,63 @@
+# Workflow and Validation
+
+## Step-by-Step Workflow
+
+### 1. Fetch Official Pricing
+
+Open the provider's official pricing page and collect input, output, cache
+write, and cache read prices.
+
+### 2. Generate a Lowercase ID
+
+```bash
+uuidgen
+```
+
+Convert the output to lowercase before using it.
+
+### 3. Create or Update the Entry
+
+Use nearby models in `worker/src/constants/default-model-prices.json` as the
+template, then:
+
+- add the new entry near related models
+- refresh `updatedAt` when editing an existing entry
+- update `packages/shared/src/server/llm/types.ts` when the model should be
+ selectable in product flows
+
+### 4. Validate the Result
+
+Run the bundled validator:
+
+```bash
+node .agents/skills/add-model-price/scripts/validate-pricing-file.mjs
+```
+
+## Validation Rules
+
+1. Exactly one default tier must have `isDefault: true`
+2. The default tier must have `priority: 0`
+3. The default tier must have `conditions: []`
+4. Non-default tiers must have `priority > 0`
+5. Non-default tiers must have at least one condition
+6. Priorities must be unique within a model
+7. Tier names must be unique within a model
+8. Each tier must contain at least one price
+9. All tiers must expose the same usage-type keys
+10. Regex patterns must be valid
+
+## Common Mistakes
+
+- Guessing prices instead of using official provider docs
+- Using MTok values directly instead of per-token values
+- Forgetting the `_tier_default` suffix on the default tier ID
+- Forgetting to escape regex metacharacters such as `.`
+- Forgetting to refresh `updatedAt`
+
+## Existing Model Templates
+
+Use nearby entries as templates:
+
+- `claude-opus-4-5-20251101` for Anthropic multi-provider patterns
+- `gpt-4o` for a simple OpenAI pattern
+- `gemini-2.5-pro` for a multi-tier Gemini entry
diff --git a/.agents/skills/add-model-price/scripts/test-match-pattern.mjs b/.agents/skills/add-model-price/scripts/test-match-pattern.mjs
new file mode 100644
index 0000000000..7e3dc7db50
--- /dev/null
+++ b/.agents/skills/add-model-price/scripts/test-match-pattern.mjs
@@ -0,0 +1,115 @@
+#!/usr/bin/env node
+
+import fs from "node:fs/promises";
+import path from "node:path";
+
+const repoRoot = process.cwd();
+const defaultFile = path.resolve(
+ repoRoot,
+ "worker/src/constants/default-model-prices.json",
+);
+const args = process.argv.slice(2);
+
+function readOption(name) {
+ const index = args.indexOf(name);
+ if (index === -1) {
+ return null;
+ }
+
+ return args[index + 1] ?? null;
+}
+
+function readListOption(name) {
+ const index = args.indexOf(name);
+ if (index === -1) {
+ return [];
+ }
+
+ const values = [];
+ for (let i = index + 1; i < args.length; i += 1) {
+ if (args[i].startsWith("--")) {
+ break;
+ }
+ values.push(args[i]);
+ }
+ return values;
+}
+
+function compilePattern(rawPattern) {
+ let source = rawPattern;
+ let flags = "";
+ const inlineFlags = rawPattern.match(/^\(\?([dgimsuvy]*)\)/);
+
+ if (inlineFlags) {
+ flags = inlineFlags[1];
+ source = rawPattern.slice(inlineFlags[0].length);
+ }
+
+ return new RegExp(source, flags);
+}
+
+let pattern = readOption("--pattern");
+const modelName = readOption("--model");
+const accepted = readListOption("--accept");
+const rejected = readListOption("--reject");
+
+if (!pattern && !modelName) {
+ console.error("Pass either --pattern <regex> or --model <modelName>.");
+ process.exit(1);
+}
+
+if (accepted.length === 0 && rejected.length === 0) {
+ console.error("Provide samples with --accept and/or --reject.");
+ process.exit(1);
+}
+
+if (!pattern && modelName) {
+ const models = JSON.parse(await fs.readFile(defaultFile, "utf8"));
+ const model = models.find((entry) => entry.modelName === modelName);
+
+ if (!model) {
+ console.error(`Model not found in pricing file: ${modelName}`);
+ process.exit(1);
+ }
+
+ pattern = model.matchPattern;
+}
+
+let regex;
+try {
+ regex = compilePattern(pattern);
+} catch (error) {
+ console.error(`Invalid pattern: ${error.message}`);
+ process.exit(1);
+}
+
+const failures = [];
+
+for (const sample of accepted) {
+ const matched = regex.test(sample);
+ console.log(`${matched ? "PASS" : "FAIL"} accept ${sample}`);
+ if (!matched) {
+ failures.push(`Expected pattern to match: ${sample}`);
+ }
+}
+
+for (const sample of rejected) {
+ const matched = regex.test(sample);
+ console.log(`${!matched ? "PASS" : "FAIL"} reject ${sample}`);
+ if (matched) {
+ failures.push(`Expected pattern to reject: ${sample}`);
+ }
+}
+
+if (failures.length > 0) {
+ console.error("");
+ for (const failure of failures) {
+ console.error(`- ${failure}`);
+ }
+ process.exit(1);
+}
+
+console.log("");
+console.log(
+ `Pattern is valid for ${accepted.length + rejected.length} sample(s).`,
+);
diff --git a/.agents/skills/add-model-price/scripts/validate-pricing-file.mjs b/.agents/skills/add-model-price/scripts/validate-pricing-file.mjs
new file mode 100644
index 0000000000..b0a417c772
--- /dev/null
+++ b/.agents/skills/add-model-price/scripts/validate-pricing-file.mjs
@@ -0,0 +1,150 @@
+#!/usr/bin/env node
+
+import fs from "node:fs/promises";
+import path from "node:path";
+
+const defaultFile = "worker/src/constants/default-model-prices.json";
+const repoRoot = process.cwd();
+const filePath = path.resolve(repoRoot, process.argv[2] ?? defaultFile);
+const failures = [];
+
+function compileMatchPattern(rawPattern, label) {
+ let source = rawPattern;
+ let flags = "";
+ const inlineFlags = rawPattern.match(/^\(\?([dgimsuvy]*)\)/);
+
+ if (inlineFlags) {
+ flags = inlineFlags[1];
+ source = rawPattern.slice(inlineFlags[0].length);
+ }
+
+ try {
+ return new RegExp(source, flags);
+ } catch (error) {
+ failures.push(`${label}: invalid matchPattern (${error.message})`);
+ return null;
+ }
+}
+
+function keysOfPrices(prices) {
+ return Object.keys(prices).sort();
+}
+
+const raw = await fs.readFile(filePath, "utf8");
+const models = JSON.parse(raw);
+
+if (!Array.isArray(models)) {
+ throw new Error("Expected the pricing file to be a JSON array.");
+}
+
+for (const model of models) {
+ const label = model.modelName ?? model.id ?? "<unknown-model>";
+
+ if (!model.id || typeof model.id !== "string") {
+ failures.push(`${label}: missing string id`);
+ }
+
+ if (!model.modelName || typeof model.modelName !== "string") {
+ failures.push(`${label}: missing string modelName`);
+ }
+
+ if (!model.matchPattern || typeof model.matchPattern !== "string") {
+ failures.push(`${label}: missing string matchPattern`);
+ } else {
+ compileMatchPattern(model.matchPattern, label);
+ }
+
+ if (Number.isNaN(Date.parse(model.createdAt ?? ""))) {
+ failures.push(`${label}: invalid createdAt timestamp`);
+ }
+
+ if (Number.isNaN(Date.parse(model.updatedAt ?? ""))) {
+ failures.push(`${label}: invalid updatedAt timestamp`);
+ }
+
+ if (!Array.isArray(model.pricingTiers) || model.pricingTiers.length === 0) {
+ failures.push(`${label}: pricingTiers must be a non-empty array`);
+ continue;
+ }
+
+ const defaultTiers = model.pricingTiers.filter((tier) => tier.isDefault);
+ if (defaultTiers.length !== 1) {
+ failures.push(`${label}: must have exactly one default tier`);
+ }
+
+ const seenPriorities = new Set();
+ const seenNames = new Set();
+ let expectedPriceKeys = null;
+
+ for (const tier of model.pricingTiers) {
+ const tierLabel = `${label}/${tier.name ?? tier.id ?? "<unknown-tier>"}`;
+
+ if (seenPriorities.has(tier.priority)) {
+ failures.push(`${tierLabel}: duplicate tier priority ${tier.priority}`);
+ } else {
+ seenPriorities.add(tier.priority);
+ }
+
+ if (seenNames.has(tier.name)) {
+ failures.push(`${tierLabel}: duplicate tier name ${tier.name}`);
+ } else {
+ seenNames.add(tier.name);
+ }
+
+ if (!tier.prices || typeof tier.prices !== "object") {
+ failures.push(`${tierLabel}: missing prices object`);
+ continue;
+ }
+
+ const priceKeys = keysOfPrices(tier.prices);
+ if (priceKeys.length === 0) {
+ failures.push(`${tierLabel}: prices object must not be empty`);
+ }
+
+ for (const [usageType, price] of Object.entries(tier.prices)) {
+ if (typeof price !== "number" || Number.isNaN(price) || price < 0) {
+ failures.push(`${tierLabel}: invalid price for ${usageType}`);
+ }
+ }
+
+ if (tier.isDefault) {
+ if (tier.priority !== 0) {
+ failures.push(`${tierLabel}: default tier priority must be 0`);
+ }
+
+ if (!Array.isArray(tier.conditions) || tier.conditions.length !== 0) {
+ failures.push(`${tierLabel}: default tier conditions must be []`);
+ }
+ } else {
+ if (!(tier.priority > 0)) {
+ failures.push(`${tierLabel}: non-default tier priority must be > 0`);
+ }
+
+ if (!Array.isArray(tier.conditions) || tier.conditions.length === 0) {
+ failures.push(
+ `${tierLabel}: non-default tiers must define at least one condition`,
+ );
+ }
+ }
+
+ if (!expectedPriceKeys) {
+ expectedPriceKeys = priceKeys.join(",");
+ } else if (expectedPriceKeys !== priceKeys.join(",")) {
+ failures.push(
+ `${tierLabel}: price keys must match the other tiers for ${label}`,
+ );
+ }
+ }
+}
+
+if (failures.length > 0) {
+ console.error("Pricing validation failed:\n");
+ for (const failure of failures) {
+ console.error(`- ${failure}`);
+ }
+ process.exit(1);
+}
+
+console.log(
+ `Validated ${models.length} pricing entries in ${path.relative(repoRoot, filePath)}.`,
+);
diff --git a/.claude/skills/backend-dev-guidelines/SKILL.md b/.agents/skills/backend-dev-guidelines/AGENTS.md
similarity index 90%
rename from .claude/skills/backend-dev-guidelines/SKILL.md
rename to .agents/skills/backend-dev-guidelines/AGENTS.md
index f8de1e76c5..c9b25cd406 100644
--- a/.claude/skills/backend-dev-guidelines/SKILL.md
+++ b/.agents/skills/backend-dev-guidelines/AGENTS.md
@@ -1,8 +1,3 @@
----
-name: backend-dev-guidelines
-description: Comprehensive backend development guide for Langfuse's Next.js 14/tRPC/Express/TypeScript monorepo. Use when creating tRPC routers, public API endpoints, BullMQ queue processors, services, or working with tRPC procedures, Next.js API routes, Prisma database access, ClickHouse analytics queries, Redis queues, OpenTelemetry instrumentation, Zod v4 validation, env.mjs configuration, tenant isolation patterns, or async patterns. Covers layered architecture (tRPC procedures β†’ services, queue processors β†’ services), dual database system (PostgreSQL + ClickHouse), projectId filtering for multi-tenant isolation, traceException error handling, observability patterns, and testing strategies (Jest for web, vitest for worker).
----
-
# Backend Development Guidelines
## Purpose
@@ -11,7 +6,7 @@ Establish consistency and best practices across Langfuse's backend packages (web
## When to Use This Skill
-Automatically activates when working on:
+Use this guide when working on:
- Creating or modifying tRPC routers and procedures
- Creating or modifying public API endpoints (REST)
@@ -105,7 +100,8 @@ Automatically activates when working on:
- **Worker**: Queue processors β†’ Services β†’ Database
- **packages/shared**: Shared code for Web and Worker
-See [architecture-overview.md](architecture-overview.md) for complete details.
+See [references/architecture-overview.md](references/architecture-overview.md)
+for complete details.
---
@@ -359,7 +355,7 @@ const result = await instrumentAsync(
### 7. Comprehensive Testing Required
-Write tests for all new features and bug fixes. See [testing-guide.md](resources/testing-guide.md) for detailed examples.
+Write tests for all new features and bug fixes. See [testing-guide.md](references/testing-guide.md) for detailed examples.
**Test Types:**
@@ -403,7 +399,7 @@ expect(rows).toHaveLength(2);
- Use unique IDs (`randomUUID()`) to avoid test interference
- Clean up test data or use unique project IDs
- Tests must be independent and runnable in any order
-- Never use `pruneDatabase` in tests
+- Prefer scoped cleanup or unique project IDs over global reset helpers
### 8. Always Filter by projectId for Tenant Isolation
@@ -536,55 +532,46 @@ Reference existing Langfuse features for implementation patterns:
| Need to... | Read this |
| ------------------------- | ------------------------------------------------------------ |
-| Understand architecture | [architecture-overview.md](resources/architecture-overview.md) |
-| Create routes/controllers | [routing-and-controllers.md](resources/routing-and-controllers.md) |
-| Organize business logic | [services-and-repositories.md](resources/services-and-repositories.md) |
-| Create middleware | [middleware-guide.md](resources/middleware-guide.md) |
-| Database access | [database-patterns.md](resources/database-patterns.md) |
-| Manage config | [configuration.md](resources/configuration.md) |
-| Write tests | [testing-guide.md](resources/testing-guide.md) |
+| Understand architecture | [architecture-overview.md](references/architecture-overview.md) |
+| Create routes/controllers | [routing-and-controllers.md](references/routing-and-controllers.md) |
+| Organize business logic | [services-and-repositories.md](references/services-and-repositories.md) |
+| Create middleware | [middleware-guide.md](references/middleware-guide.md) |
+| Database access | [database-patterns.md](references/database-patterns.md) |
+| Manage config | [configuration.md](references/configuration.md) |
+| Write tests | [testing-guide.md](references/testing-guide.md) |
---
-## Resource Files
+## Reference Files
-### [architecture-overview.md](resources/architecture-overview.md)
+### [architecture-overview.md](references/architecture-overview.md)
Three-layer architecture (tRPC/Public API β†’ Services β†’ Data Access), request lifecycle for tRPC/Public API/Worker, Next.js 14 directory structure, dual database system (PostgreSQL + ClickHouse), separation of concerns, repository pattern for complex queries
-### [routing-and-controllers.md](resources/routing-and-controllers.md)
+### [routing-and-controllers.md](references/routing-and-controllers.md)
Next.js file-based routing, tRPC router patterns, Public REST API routes, layered architecture (Entry Points β†’ Services β†’ Repositories β†’ Database), service layer organization, anti-patterns to avoid
-### [services-and-repositories.md](resources/services-and-repositories.md)
+### [services-and-repositories.md](references/services-and-repositories.md)
Service layer overview, dependency injection patterns, singleton patterns, repository pattern for data access, service design principles, caching strategies, testing services
-### [middleware-guide.md](resources/middleware-guide.md)
+### [middleware-guide.md](references/middleware-guide.md)
tRPC middleware (withErrorHandling, withOtelInstrumentation, enforceUserIsAuthed), seven tRPC procedure types (publicProcedure, authenticatedProcedure, protectedProjectProcedure, etc.), Public API middleware (withMiddlewares, createAuthedProjectAPIRoute), authentication patterns (NextAuth for tRPC, Basic Auth for Public API)
-### [database-patterns.md](resources/database-patterns.md)
+### [database-patterns.md](references/database-patterns.md)
Dual database architecture (PostgreSQL via Prisma + ClickHouse via direct client), PostgreSQL CRUD operations, ClickHouse query patterns (queryClickhouse, queryClickhouseStream, upsertClickhouse), repository pattern for complex queries, tenant isolation with projectId filtering, when to use which database
-### [configuration.md](resources/configuration.md)
+### [configuration.md](references/configuration.md)
Environment variable validation with Zod, package-specific configs (web/env.mjs with t3-oss/env-nextjs, worker/env.ts, shared/env.ts), NEXT_PUBLIC_LANGFUSE_CLOUD_REGION usage, LANGFUSE_EE_LICENSE_KEY for enterprise features, best practices for env management
-### [testing-guide.md](resources/testing-guide.md)
+### [testing-guide.md](references/testing-guide.md)
Integration tests (Public API with makeZodVerifiedAPICall), tRPC tests (createInnerTRPCContext, appRouter.createCaller), service-level tests (repository/service functions), worker tests (vitest with streams), test isolation principles, running tests (Jest for web, vitest for worker)
----
-
-## Related Skills
-
-- **database-verification** - Verify column names and schema consistency
-- **skill-developer** - Meta-skill for creating and managing skills
-
----
-
**Skill Status**: COMPLETE βœ…
**Line Count**: ~540 lines
-**Progressive Disclosure**: 7 resource files βœ…
+**Progressive Disclosure**: 7 reference files βœ…
diff --git a/.agents/skills/backend-dev-guidelines/SKILL.md b/.agents/skills/backend-dev-guidelines/SKILL.md
new file mode 100644
index 0000000000..cff41f10f1
--- /dev/null
+++ b/.agents/skills/backend-dev-guidelines/SKILL.md
@@ -0,0 +1,43 @@
+---
+name: backend-dev-guidelines
+description: Shared backend guide for Langfuse's Next.js 14, tRPC, BullMQ, and TypeScript monorepo. Use when creating or reviewing tRPC routers, public REST endpoints, BullMQ queue processors, backend services, middleware, Prisma or ClickHouse data access, OpenTelemetry instrumentation, Zod validation, env configuration, or backend tests across web, worker, or packages/shared.
+---
+
+# Backend Development Guidelines
+
+Use this skill for backend and API work across `web/`, `worker/`, and
+`packages/shared/`.
+
+## When to Apply
+
+- Creating or modifying tRPC routers and procedures
+- Creating or modifying public API endpoints
+- Creating or modifying queue processors, producers, or queue-backed workflows
+- Building or refactoring backend services and repositories
+- Working on backend auth, middleware, validation, or observability
+- Updating Prisma or ClickHouse access patterns
+- Adding or fixing backend tests
+
+## How to Read This Skill
+
+- Start with [AGENTS.md](AGENTS.md) when the task spans multiple backend areas
+ or you need the end-to-end checklists.
+- Read only the specific reference file that matches the work when the scope is
+ narrower.
+
+## Reference Map
+
+| Topic | Read this when | File |
+| --- | --- | --- |
+| Architecture and package boundaries | You need the web/worker/shared split, request flow, or queue lifecycle | [references/architecture-overview.md](references/architecture-overview.md) |
+| Routing and controllers | You are writing tRPC procedures, public API routes, or queue entrypoints | [references/routing-and-controllers.md](references/routing-and-controllers.md) |
+| Middleware and auth | You are changing request auth, permissions, or middleware composition | [references/middleware-guide.md](references/middleware-guide.md) |
+| Services and repositories | You are placing business logic, repository code, or DI patterns | [references/services-and-repositories.md](references/services-and-repositories.md) |
+| Database access | You are touching Prisma, ClickHouse, tenant filters, or query patterns | [references/database-patterns.md](references/database-patterns.md) |
+| Configuration | You are adding env vars, startup config, or runtime toggles | [references/configuration.md](references/configuration.md) |
+| Testing | You are adding or updating backend tests | [references/testing-guide.md](references/testing-guide.md) |
+
+## Full Compiled Guide
+
+Read [AGENTS.md](AGENTS.md) for the complete backend guide with checklists,
+directory conventions, imports, architecture, and cross-cutting practices.
diff --git a/.claude/skills/backend-dev-guidelines/resources/architecture-overview.md b/.agents/skills/backend-dev-guidelines/references/architecture-overview.md
similarity index 99%
rename from .claude/skills/backend-dev-guidelines/resources/architecture-overview.md
rename to .agents/skills/backend-dev-guidelines/references/architecture-overview.md
index f3323df7b1..288292a2f2 100644
--- a/.claude/skills/backend-dev-guidelines/resources/architecture-overview.md
+++ b/.agents/skills/backend-dev-guidelines/references/architecture-overview.md
@@ -864,7 +864,7 @@ const validated = bodySchema.parse(req.body);
**Related Files:**
-- [SKILL.md](../SKILL.md) - Main guide
+- [../AGENTS.md](../AGENTS.md) - Main guide
- [routing-and-controllers.md](routing-and-controllers.md) - tRPC and Public API details
- [services-and-repositories.md](services-and-repositories.md) - Service patterns
- [testing-guide.md](testing-guide.md) - Testing strategies
diff --git a/.claude/skills/backend-dev-guidelines/resources/configuration.md b/.agents/skills/backend-dev-guidelines/references/configuration.md
similarity index 99%
rename from .claude/skills/backend-dev-guidelines/resources/configuration.md
rename to .agents/skills/backend-dev-guidelines/references/configuration.md
index 25bb7877d7..19475714f8 100644
--- a/.claude/skills/backend-dev-guidelines/resources/configuration.md
+++ b/.agents/skills/backend-dev-guidelines/references/configuration.md
@@ -559,5 +559,5 @@ langfuse/
**Related Files:**
-- [SKILL.md](../SKILL.md) - Main guide
+- [../AGENTS.md](../AGENTS.md) - Main guide
- [architecture-overview.md](architecture-overview.md) - Architecture patterns
diff --git a/.claude/skills/backend-dev-guidelines/resources/database-patterns.md b/.agents/skills/backend-dev-guidelines/references/database-patterns.md
similarity index 99%
rename from .claude/skills/backend-dev-guidelines/resources/database-patterns.md
rename to .agents/skills/backend-dev-guidelines/references/database-patterns.md
index df4196dba3..10a995c81c 100644
--- a/.claude/skills/backend-dev-guidelines/resources/database-patterns.md
+++ b/.agents/skills/backend-dev-guidelines/references/database-patterns.md
@@ -655,6 +655,6 @@ LANGFUSE_CLICKHOUSE_QUERY_MAX_ATTEMPTS: z.coerce.number().positive().default(3)
**Related Files:**
-- [SKILL.md](../SKILL.md) - Main backend development guidelines
+- [../AGENTS.md](../AGENTS.md) - Main backend development guidelines
- [architecture-overview.md](architecture-overview.md) - System architecture
- [configuration.md](configuration.md) - Environment variable configuration
diff --git a/.claude/skills/backend-dev-guidelines/resources/middleware-guide.md b/.agents/skills/backend-dev-guidelines/references/middleware-guide.md
similarity index 99%
rename from .claude/skills/backend-dev-guidelines/resources/middleware-guide.md
rename to .agents/skills/backend-dev-guidelines/references/middleware-guide.md
index cebfc57984..d4664ce7e8 100644
--- a/.claude/skills/backend-dev-guidelines/resources/middleware-guide.md
+++ b/.agents/skills/backend-dev-guidelines/references/middleware-guide.md
@@ -760,6 +760,6 @@ ctx.trace // TraceRecord (pre-fetched)
**Related Files:**
-- [SKILL.md](../SKILL.md) - Main backend development guidelines
+- [../AGENTS.md](../AGENTS.md) - Main backend development guidelines
- [architecture-overview.md](architecture-overview.md) - System architecture
-- [async-and-errors.md](async-and-errors.md) - Error handling patterns
+- [../AGENTS.md](../AGENTS.md) - Error handling patterns and traceException guidance
diff --git a/.claude/skills/backend-dev-guidelines/resources/routing-and-controllers.md b/.agents/skills/backend-dev-guidelines/references/routing-and-controllers.md
similarity index 99%
rename from .claude/skills/backend-dev-guidelines/resources/routing-and-controllers.md
rename to .agents/skills/backend-dev-guidelines/references/routing-and-controllers.md
index 99fec4c5d6..745ebe21c9 100644
--- a/.claude/skills/backend-dev-guidelines/resources/routing-and-controllers.md
+++ b/.agents/skills/backend-dev-guidelines/references/routing-and-controllers.md
@@ -838,7 +838,7 @@ export const upsertScore = async (
**Related Files:**
-- [SKILL.md](../SKILL.md) - Main backend development guidelines
+- [../AGENTS.md](../AGENTS.md) - Main backend development guidelines
- [architecture-overview.md](architecture-overview.md) - System architecture
- [middleware-guide.md](middleware-guide.md) - Middleware patterns
- [database-patterns.md](database-patterns.md) - Database access patterns
diff --git a/.claude/skills/backend-dev-guidelines/resources/services-and-repositories.md b/.agents/skills/backend-dev-guidelines/references/services-and-repositories.md
similarity index 99%
rename from .claude/skills/backend-dev-guidelines/resources/services-and-repositories.md
rename to .agents/skills/backend-dev-guidelines/references/services-and-repositories.md
index bad72587a6..737b2020b8 100644
--- a/.claude/skills/backend-dev-guidelines/resources/services-and-repositories.md
+++ b/.agents/skills/backend-dev-guidelines/references/services-and-repositories.md
@@ -871,7 +871,7 @@ describe("UserService", () => {
**Related Files:**
-- [SKILL.md](SKILL.md) - Main guide
+- [../AGENTS.md](../AGENTS.md) - Main guide
- [routing-and-controllers.md](routing-and-controllers.md) - Controllers that use services
- [database-patterns.md](database-patterns.md) - Prisma and repository patterns
-- [complete-examples.md](complete-examples.md) - Full service/repository examples
+- [testing-guide.md](testing-guide.md) - Testing service and repository code
diff --git a/.claude/skills/backend-dev-guidelines/resources/testing-guide.md b/.agents/skills/backend-dev-guidelines/references/testing-guide.md
similarity index 98%
rename from .claude/skills/backend-dev-guidelines/resources/testing-guide.md
rename to .agents/skills/backend-dev-guidelines/references/testing-guide.md
index 4a69ca9c70..672ce5d6cd 100644
--- a/.claude/skills/backend-dev-guidelines/resources/testing-guide.md
+++ b/.agents/skills/backend-dev-guidelines/references/testing-guide.md
@@ -471,7 +471,7 @@ describe("batch export test suite", () => {
1. **Test Isolation**: Each test should be independent and runnable in any order
2. **Unique IDs**: Use `randomUUID()` or unique project IDs to avoid test interference
3. **Cleanup**: Always clean up test data in service tests (or use unique project IDs)
-4. **No `pruneDatabase`**: Avoid `pruneDatabase` calls, especially in `__tests__/async/` directory
+4. **Avoid Global Resets**: Prefer scoped cleanup or unique project IDs over global reset helpers
### By Test Type
@@ -499,9 +499,6 @@ const { projectId } = await createOrgProjectAndApiKey();
// ❌ BAD: Shared test data between tests
const projectId = "7a88fb47-b4e2-43b8-a06c-a5ce950dc53a";
-
-// ❌ BAD: Using pruneDatabase
-await pruneDatabase();
```
---
@@ -553,6 +550,6 @@ pnpm run test --filter=worker -- --coverage
---
**Related Files:**
-- [SKILL.md](../SKILL.md) - Main backend guidelines
+- [../AGENTS.md](../AGENTS.md) - Main backend guidelines
- [architecture-overview.md](architecture-overview.md) - Architecture patterns
-- [complete-examples.md](complete-examples.md) - Full code examples
+- [services-and-repositories.md](services-and-repositories.md) - Service and repository examples
diff --git a/.claude/hooks/CONFIG.md b/.claude/hooks/CONFIG.md
deleted file mode 100644
index c110b7c0a3..0000000000
--- a/.claude/hooks/CONFIG.md
+++ /dev/null
@@ -1,436 +0,0 @@
-# Hooks Configuration Guide
-
-This guide explains how to configure and customize the hooks system for your project.
-
-## Quick Start Configuration
-
-### 1. Register Hooks in .claude/settings.json
-
-Create or update `.claude/settings.json` in your project root:
-
-```json
-{
- "hooks": {
- "UserPromptSubmit": [
- {
- "hooks": [
- {
- "type": "command",
- "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/skill-activation-prompt.sh"
- }
- ]
- }
- ],
- "Stop": [
- {
- "hooks": [
- {
- "type": "command",
- "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/error-handling-reminder.sh"
- }
- ]
- }
- ]
- }
-}
-```
-
-### 2. Install Dependencies
-
-```bash
-cd .claude/hooks
-npm install
-```
-
-### 3. Set Execute Permissions
-
-```bash
-chmod +x .claude/hooks/*.sh
-```
-
-## Customization Options
-
-### Project Structure Detection
-
-By default, hooks detect these directory patterns:
-
-**Frontend:** `frontend/`, `client/`, `web/`, `app/`, `ui/`
-**Backend:** `backend/`, `server/`, `api/`, `src/`, `services/`
-**Database:** `database/`, `prisma/`, `migrations/`
-**Monorepo:** `packages/*`, `examples/*`
-
-#### Adding Custom Directory Patterns
-
-Edit `.claude/hooks/post-tool-use-tracker.sh`, function `detect_repo()`:
-
-```bash
-case "$repo" in
- # Add your custom directories here
- my-custom-service)
- echo "$repo"
- ;;
- admin-panel)
- echo "$repo"
- ;;
- # ... existing patterns
-esac
-```
-
-### Build Command Detection
-
-The hooks auto-detect build commands based on:
-
-1. Presence of `package.json` with "build" script
-2. Package manager (pnpm > npm > yarn)
-3. Special cases (Prisma schemas)
-
-#### Customizing Build Commands
-
-Edit `.claude/hooks/post-tool-use-tracker.sh`, function `get_build_command()`:
-
-```bash
-# Add custom build logic
-if [[ "$repo" == "my-service" ]]; then
- echo "cd $repo_path && make build"
- return
-fi
-```
-
-### TypeScript Configuration
-
-Hooks automatically detect:
-
-- `tsconfig.json` for standard TypeScript projects
-- `tsconfig.app.json` for Vite/React projects
-
-#### Custom TypeScript Configs
-
-Edit `.claude/hooks/post-tool-use-tracker.sh`, function `get_tsc_command()`:
-
-```bash
-if [[ "$repo" == "my-service" ]]; then
- echo "cd $repo_path && npx tsc --project tsconfig.build.json --noEmit"
- return
-fi
-```
-
-### Prettier Configuration
-
-The prettier hook searches for configs in this order:
-
-1. Current file directory (walking upward)
-2. Project root
-3. Falls back to Prettier defaults
-
-#### Custom Prettier Config Search
-
-Edit `.claude/hooks/stop-prettier-formatter.sh`, function `get_prettier_config()`:
-
-```bash
-# Add custom config locations
-if [[ -f "$project_root/config/.prettierrc" ]]; then
- echo "$project_root/config/.prettierrc"
- return
-fi
-```
-
-### Error Handling Reminders
-
-Configure file category detection in `.claude/hooks/error-handling-reminder.ts`:
-
-```typescript
-function getFileCategory(
- filePath: string,
-): "backend" | "frontend" | "database" | "other" {
- // Add custom patterns
- if (filePath.includes("/my-custom-dir/")) return "backend";
- // ... existing patterns
-}
-```
-
-### Error Threshold Configuration
-
-Change when to recommend the auto-error-resolver agent.
-
-Edit `.claude/hooks/stop-build-check-enhanced.sh`:
-
-```bash
-# Default is 5 errors - change to your preference
-if [[ $total_errors -ge 10 ]]; then # Now requires 10+ errors
- # Recommend agent
-fi
-```
-
-## Environment Variables
-
-### Global Environment Variables
-
-Set in your shell profile (`.bashrc`, `.zshrc`, etc.):
-
-```bash
-# Disable error handling reminders
-export SKIP_ERROR_REMINDER=1
-
-# Custom project directory (if not using default)
-export CLAUDE_PROJECT_DIR=/path/to/your/project
-```
-
-### Per-Session Environment Variables
-
-Set before starting Claude Code:
-
-```bash
-SKIP_ERROR_REMINDER=1 claude-code
-```
-
-## Hook Execution Order
-
-Stop hooks run in the order specified in `settings.json`:
-
-```json
-"Stop": [
- {
- "hooks": [
- { "command": "...formatter.sh" }, // Runs FIRST
- { "command": "...build-check.sh" }, // Runs SECOND
- { "command": "...reminder.sh" } // Runs THIRD
- ]
- }
-]
-```
-
-**Why this order matters:**
-
-1. Format files first (clean code)
-2. Then check for errors
-3. Finally show reminders
-
-## Selective Hook Enabling
-
-You don't need all hooks. Choose what works for your project:
-
-### Minimal Setup (Skill Activation Only)
-
-```json
-{
- "hooks": {
- "UserPromptSubmit": [
- {
- "hooks": [
- {
- "type": "command",
- "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/skill-activation-prompt.sh"
- }
- ]
- }
- ]
- }
-}
-```
-
-### Build Checking Only (No Formatting)
-
-```json
-{
- "hooks": {
- "PostToolUse": [
- {
- "matcher": "Edit|MultiEdit|Write",
- "hooks": [
- {
- "type": "command",
- "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/post-tool-use-tracker.sh"
- }
- ]
- }
- ],
- "Stop": [
- {
- "hooks": [
- {
- "type": "command",
- "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/stop-build-check-enhanced.sh"
- }
- ]
- }
- ]
- }
-}
-```
-
-### Formatting Only (No Build Checking)
-
-```json
-{
- "hooks": {
- "PostToolUse": [
- {
- "matcher": "Edit|MultiEdit|Write",
- "hooks": [
- {
- "type": "command",
- "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/post-tool-use-tracker.sh"
- }
- ]
- }
- ],
- "Stop": [
- {
- "hooks": [
- {
- "type": "command",
- "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/stop-prettier-formatter.sh"
- }
- ]
- }
- ]
- }
-}
-```
-
-## Cache Management
-
-### Cache Location
-
-```
-$CLAUDE_PROJECT_DIR/.claude/tsc-cache/[session_id]/
-```
-
-### Manual Cache Cleanup
-
-```bash
-# Remove all cached data
-rm -rf $CLAUDE_PROJECT_DIR/.claude/tsc-cache/*
-
-# Remove specific session
-rm -rf $CLAUDE_PROJECT_DIR/.claude/tsc-cache/[session-id]
-```
-
-### Automatic Cleanup
-
-The build-check hook automatically cleans up session cache on successful builds.
-
-## Troubleshooting Configuration
-
-### Hook Not Executing
-
-1. **Check registration:** Verify hook is in `.claude/settings.json`
-2. **Check permissions:** Run `chmod +x .claude/hooks/*.sh`
-3. **Check path:** Ensure `$CLAUDE_PROJECT_DIR` is set correctly
-4. **Check TypeScript:** Run `cd .claude/hooks && npx tsc` to check for errors
-
-### False Positive Detections
-
-**Issue:** Hook triggers for files it shouldn't
-
-**Solution:** Add skip conditions in the relevant hook:
-
-```bash
-# In post-tool-use-tracker.sh
-if [[ "$file_path" =~ /generated/ ]]; then
- exit 0 # Skip generated files
-fi
-```
-
-### Performance Issues
-
-**Issue:** Hooks are slow
-
-**Solutions:**
-
-1. Limit TypeScript checks to changed files only
-2. Use faster package managers (pnpm > npm)
-3. Add more skip conditions
-4. Disable Prettier for large files
-
-```bash
-# Skip large files in stop-prettier-formatter.sh
-file_size=$(wc -c < "$file" 2>/dev/null || echo 0)
-if [[ $file_size -gt 100000 ]]; then # Skip files > 100KB
- continue
-fi
-```
-
-### Debugging Hooks
-
-Add debug output to any hook:
-
-```bash
-# At the top of the hook script
-set -x # Enable debug mode
-
-# Or add specific debug lines
-echo "DEBUG: file_path=$file_path" >&2
-echo "DEBUG: repo=$repo" >&2
-```
-
-View hook execution in Claude Code's logs.
-
-## Advanced Configuration
-
-### Custom Hook Event Handlers
-
-You can create your own hooks for other events:
-
-```json
-{
- "hooks": {
- "PreToolUse": [
- {
- "matcher": "Bash",
- "hooks": [
- {
- "type": "command",
- "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/my-custom-bash-guard.sh"
- }
- ]
- }
- ]
- }
-}
-```
-
-### Monorepo Configuration
-
-For monorepos with multiple packages:
-
-```bash
-# In post-tool-use-tracker.sh, detect_repo()
-case "$repo" in
- packages)
- # Get the package name
- local package=$(echo "$relative_path" | cut -d'/' -f2)
- if [[ -n "$package" ]]; then
- echo "packages/$package"
- else
- echo "$repo"
- fi
- ;;
-esac
-```
-
-### Docker/Container Projects
-
-If your build commands need to run in containers:
-
-```bash
-# In post-tool-use-tracker.sh, get_build_command()
-if [[ "$repo" == "api" ]]; then
- echo "docker-compose exec api npm run build"
- return
-fi
-```
-
-## Best Practices
-
-1. **Start minimal** - Enable hooks one at a time
-2. **Test thoroughly** - Make changes and verify hooks work
-3. **Document customizations** - Add comments to explain custom logic
-4. **Version control** - Commit `.claude/` directory to git
-5. **Team consistency** - Share configuration across team
-
-## See Also
-
-- [README.md](./README.md) - Hooks overview
-- [../../docs/HOOKS_SYSTEM.md](../../docs/HOOKS_SYSTEM.md) - Complete hooks reference
-- [../../docs/SKILLS_SYSTEM.md](../../docs/SKILLS_SYSTEM.md) - Skills integration
diff --git a/.claude/hooks/README.md b/.claude/hooks/README.md
deleted file mode 100644
index 0ee9b6dd99..0000000000
--- a/.claude/hooks/README.md
+++ /dev/null
@@ -1,116 +0,0 @@
-# Hooks
-
-Claude Code hooks that enable skill auto-activation, file tracking, and validation.
-
----
-
-## What Are Hooks?
-
-Hooks are scripts that run at specific points in Claude's workflow:
-
-- **UserPromptSubmit**: When user submits a prompt
-- **PreToolUse**: Before a tool executes
-- **PostToolUse**: After a tool completes
-- **Stop**: When user requests to stop
-
-**Key insight:** Hooks can modify prompts, block actions, and track state - enabling features Claude can't do alone.
-
----
-
-## Essential Hooks (Start Here)
-
-### skill-activation-prompt (UserPromptSubmit)
-
-**Purpose:** Automatically suggests relevant skills based on user prompts and file context
-
-**How it works:**
-
-1. Reads `skill-rules.json`
-2. Matches user prompt against trigger patterns
-3. Checks which files user is working with
-4. Injects skill suggestions into Claude's context
-
-**Why it's essential:** This is THE hook that makes skills auto-activate.
-
-**Integration:**
-
-```bash
-# Copy both files
-cp skill-activation-prompt.sh your-project/.claude/hooks/
-cp skill-activation-prompt.ts your-project/.claude/hooks/
-
-# Make executable
-chmod +x your-project/.claude/hooks/skill-activation-prompt.sh
-
-# Install dependencies
-cd your-project/.claude/hooks
-npm install
-```
-
-**Add to settings.json:**
-
-```json
-{
- "hooks": {
- "UserPromptSubmit": [
- {
- "hooks": [
- {
- "type": "command",
- "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/skill-activation-prompt.sh"
- }
- ]
- }
- ]
- }
-}
-```
-
-**Customization:** βœ… None needed - reads skill-rules.json automatically
-
----
-
-### post-tool-use-tracker (PostToolUse)
-
-**Purpose:** Tracks file changes to maintain context across sessions
-
-**How it works:**
-
-1. Monitors Edit/Write/MultiEdit tool calls
-2. Records which files were modified
-3. Creates cache for context management
-4. Auto-detects project structure (frontend, backend, packages, etc.)
-
-**Why it's essential:** Helps Claude understand what parts of your codebase are active.
-
-**Integration:**
-
-```bash
-# Copy file
-cp post-tool-use-tracker.sh your-project/.claude/hooks/
-
-# Make executable
-chmod +x your-project/.claude/hooks/post-tool-use-tracker.sh
-```
-
-**Add to settings.json:**
-
-```json
-{
- "hooks": {
- "PostToolUse": [
- {
- "matcher": "Edit|MultiEdit|Write",
- "hooks": [
- {
- "type": "command",
- "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/post-tool-use-tracker.sh"
- }
- ]
- }
- ]
- }
-}
-```
-
-**Customization:** βœ… None needed - auto-detects structure
diff --git a/.claude/hooks/error-handling-reminder.sh b/.claude/hooks/error-handling-reminder.sh
deleted file mode 100644
index de28a794be..0000000000
--- a/.claude/hooks/error-handling-reminder.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/bash
-
-# Skip if environment variable is set
-if [ -n "$SKIP_ERROR_REMINDER" ]; then
- exit 0
-fi
-
-# Get the directory of this script
-SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
-cd "$SCRIPT_DIR"
-
-cat | npx tsx error-handling-reminder.ts
diff --git a/.claude/hooks/error-handling-reminder.ts b/.claude/hooks/error-handling-reminder.ts
deleted file mode 100644
index 3a72461138..0000000000
--- a/.claude/hooks/error-handling-reminder.ts
+++ /dev/null
@@ -1,256 +0,0 @@
-#!/usr/bin/env node
-import { readFileSync, existsSync } from "fs";
-import { join } from "path";
-
-interface HookInput {
- session_id: string;
- transcript_path: string;
- cwd: string;
- permission_mode: string;
- hook_event_name: string;
-}
-
-interface EditedFile {
- path: string;
- tool: string;
- timestamp: string;
-}
-
-interface SessionTracking {
- edited_files: EditedFile[];
-}
-
-function getFileCategory(
- filePath: string,
-): "backend" | "frontend" | "database" | "other" {
- // Frontend detection
- if (
- filePath.includes("/frontend/") ||
- filePath.includes("/client/") ||
- filePath.includes("/src/components/") ||
- filePath.includes("/src/features/")
- )
- return "frontend";
-
- // Backend detection (common service directories)
- if (
- filePath.includes("/src/controllers/") ||
- filePath.includes("/src/services/") ||
- filePath.includes("/src/routes/") ||
- filePath.includes("/src/api/") ||
- filePath.includes("/server/")
- )
- return "backend";
-
- // Database detection
- if (
- filePath.includes("/database/") ||
- filePath.includes("/prisma/") ||
- filePath.includes("/migrations/")
- )
- return "database";
-
- return "other";
-}
-
-function shouldCheckErrorHandling(filePath: string): boolean {
- // Skip test files, config files, and type definitions
- if (filePath.match(/\.(test|spec)\.(ts|tsx)$/)) return false;
- if (filePath.match(/\.(config|d)\.(ts|tsx)$/)) return false;
- if (filePath.includes("types/")) return false;
- if (filePath.includes(".styles.ts")) return false;
-
- // Check for code files
- return filePath.match(/\.(ts|tsx|js|jsx)$/) !== null;
-}
-
-function analyzeFileContent(filePath: string): {
- hasTryCatch: boolean;
- hasAsync: boolean;
- hasPrisma: boolean;
- hasController: boolean;
- hasApiCall: boolean;
-} {
- if (!existsSync(filePath)) {
- return {
- hasTryCatch: false,
- hasAsync: false,
- hasPrisma: false,
- hasController: false,
- hasApiCall: false,
- };
- }
-
- const content = readFileSync(filePath, "utf-8");
-
- return {
- hasTryCatch: /try\s*\{/.test(content),
- hasAsync: /async\s+/.test(content),
- hasPrisma:
- /prisma\.|PrismaService|findMany|findUnique|create\(|update\(|delete\(/i.test(
- content,
- ),
- hasController:
- /export class.*Controller|router\.|app\.(get|post|put|delete|patch)/.test(
- content,
- ),
- hasApiCall: /fetch\(|axios\.|apiClient\./i.test(content),
- };
-}
-
-async function main() {
- try {
- // Read input from stdin
- const input = readFileSync(0, "utf-8");
- const data: HookInput = JSON.parse(input);
-
- const { session_id } = data;
- const projectDir = process.env.CLAUDE_PROJECT_DIR || process.cwd();
-
- // Check for edited files tracking
- const cacheDir = join(
- process.env.HOME || "/root",
- ".claude",
- "tsc-cache",
- session_id,
- );
- const trackingFile = join(cacheDir, "edited-files.log");
-
- if (!existsSync(trackingFile)) {
- // No files edited this session, no reminder needed
- process.exit(0);
- }
-
- // Read tracking data
- const trackingContent = readFileSync(trackingFile, "utf-8");
- const editedFiles = trackingContent
- .trim()
- .split("\n")
- .filter((line) => line.length > 0)
- .map((line) => {
- const [timestamp, tool, path] = line.split("\t");
- return { timestamp, tool, path };
- });
-
- if (editedFiles.length === 0) {
- process.exit(0);
- }
-
- // Categorize files
- const categories = {
- backend: [] as string[],
- frontend: [] as string[],
- database: [] as string[],
- other: [] as string[],
- };
-
- const analysisResults: Array<{
- path: string;
- category: string;
- analysis: ReturnType<typeof analyzeFileContent>;
- }> = [];
-
- for (const file of editedFiles) {
- if (!shouldCheckErrorHandling(file.path)) continue;
-
- const category = getFileCategory(file.path);
- categories[category].push(file.path);
-
- const analysis = analyzeFileContent(file.path);
- analysisResults.push({ path: file.path, category, analysis });
- }
-
- // Check if any code that needs error handling was written
- const needsAttention = analysisResults.some(
- ({ analysis }) =>
- analysis.hasTryCatch ||
- analysis.hasAsync ||
- analysis.hasPrisma ||
- analysis.hasController ||
- analysis.hasApiCall,
- );
-
- if (!needsAttention) {
- // No risky code patterns detected, skip reminder
- process.exit(0);
- }
-
- // Display reminder
- console.log("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
- console.log("πŸ“‹ ERROR HANDLING SELF-CHECK");
- console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
-
- // Backend reminders
- if (categories.backend.length > 0) {
- const backendFiles = analysisResults.filter(
- (f) => f.category === "backend",
- );
- const hasTryCatch = backendFiles.some((f) => f.analysis.hasTryCatch);
- const hasPrisma = backendFiles.some((f) => f.analysis.hasPrisma);
- const hasController = backendFiles.some((f) => f.analysis.hasController);
-
- console.log("⚠️ Backend Changes Detected");
- console.log(` ${categories.backend.length} file(s) edited\n`);
-
- if (hasTryCatch) {
- console.log(
- " ❓ Did you add Sentry.captureException() in catch blocks?",
- );
- }
- if (hasPrisma) {
- console.log(" ❓ Are Prisma operations wrapped in error handling?");
- }
- if (hasController) {
- console.log(" ❓ Do controllers use BaseController.handleError()?");
- }
-
- console.log("\n πŸ’‘ Backend Best Practice:");
- console.log(" - All errors should be captured to Sentry");
- console.log(" - Use appropriate error helpers for context");
- console.log(" - Controllers should extend BaseController\n");
- }
-
- // Frontend reminders
- if (categories.frontend.length > 0) {
- const frontendFiles = analysisResults.filter(
- (f) => f.category === "frontend",
- );
- const hasApiCall = frontendFiles.some((f) => f.analysis.hasApiCall);
- const hasTryCatch = frontendFiles.some((f) => f.analysis.hasTryCatch);
-
- console.log("πŸ’‘ Frontend Changes Detected");
- console.log(` ${categories.frontend.length} file(s) edited\n`);
-
- if (hasApiCall) {
- console.log(" ❓ Do API calls show user-friendly error messages?");
- }
- if (hasTryCatch) {
- console.log(" ❓ Are errors displayed to the user?");
- }
-
- console.log("\n πŸ’‘ Frontend Best Practice:");
- console.log(" - Use your notification system for user feedback");
- console.log(" - Error boundaries for component errors");
- console.log(" - Display user-friendly error messages\n");
- }
-
- // Database reminders
- if (categories.database.length > 0) {
- console.log("πŸ—„οΈ Database Changes Detected");
- console.log(` ${categories.database.length} file(s) edited\n`);
- console.log(" ❓ Did you verify column names against schema?");
- console.log(" ❓ Are migrations tested?\n");
- }
-
- console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
- console.log("πŸ’‘ TIP: Disable with SKIP_ERROR_REMINDER=1");
- console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
-
- process.exit(0);
- } catch (err) {
- // Silently fail - this is just a reminder, not critical
- process.exit(0);
- }
-}
-
-main().catch(() => process.exit(0));
diff --git a/.claude/hooks/package-lock.json b/.claude/hooks/package-lock.json
deleted file mode 100644
index b90b38532e..0000000000
--- a/.claude/hooks/package-lock.json
+++ /dev/null
@@ -1,556 +0,0 @@
-{
- "name": "claude-hooks",
- "version": "1.0.0",
- "lockfileVersion": 3,
- "requires": true,
- "packages": {
- "": {
- "name": "claude-hooks",
- "version": "1.0.0",
- "dependencies": {
- "@types/node": "^20.11.0",
- "tsx": "^4.7.0",
- "typescript": "^5.3.3"
- }
- },
- "node_modules/@esbuild/aix-ppc64": {
- "version": "0.25.11",
- "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.11.tgz",
- "integrity": "sha512-Xt1dOL13m8u0WE8iplx9Ibbm+hFAO0GsU2P34UNoDGvZYkY8ifSiy6Zuc1lYxfG7svWE2fzqCUmFp5HCn51gJg==",
- "cpu": [
- "ppc64"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "aix"
- ],
- "engines": {
- "node": ">=18"
- }
- },
- "node_modules/@esbuild/android-arm": {
- "version": "0.25.11",
- "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.11.tgz",
- "integrity": "sha512-uoa7dU+Dt3HYsethkJ1k6Z9YdcHjTrSb5NUy66ZfZaSV8hEYGD5ZHbEMXnqLFlbBflLsl89Zke7CAdDJ4JI+Gg==",
- "cpu": [
- "arm"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "android"
- ],
- "engines": {
- "node": ">=18"
- }
- },
- "node_modules/@esbuild/android-arm64": {
- "version": "0.25.11",
- "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.11.tgz",
- "integrity": "sha512-9slpyFBc4FPPz48+f6jyiXOx/Y4v34TUeDDXJpZqAWQn/08lKGeD8aDp9TMn9jDz2CiEuHwfhRmGBvpnd/PWIQ==",
- "cpu": [
- "arm64"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "android"
- ],
- "engines": {
- "node": ">=18"
- }
- },
- "node_modules/@esbuild/android-x64": {
- "version": "0.25.11",
- "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.11.tgz",
- "integrity": "sha512-Sgiab4xBjPU1QoPEIqS3Xx+R2lezu0LKIEcYe6pftr56PqPygbB7+szVnzoShbx64MUupqoE0KyRlN7gezbl8g==",
- "cpu": [
- "x64"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "android"
- ],
- "engines": {
- "node": ">=18"
- }
- },
- "node_modules/@esbuild/darwin-arm64": {
- "version": "0.25.11",
- "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.11.tgz",
- "integrity": "sha512-VekY0PBCukppoQrycFxUqkCojnTQhdec0vevUL/EDOCnXd9LKWqD/bHwMPzigIJXPhC59Vd1WFIL57SKs2mg4w==",
- "cpu": [
- "arm64"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "darwin"
- ],
- "engines": {
- "node": ">=18"
- }
- },
- "node_modules/@esbuild/darwin-x64": {
- "version": "0.25.11",
- "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.11.tgz",
- "integrity": "sha512-+hfp3yfBalNEpTGp9loYgbknjR695HkqtY3d3/JjSRUyPg/xd6q+mQqIb5qdywnDxRZykIHs3axEqU6l1+oWEQ==",
- "cpu": [
- "x64"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "darwin"
- ],
- "engines": {
- "node": ">=18"
- }
- },
- "node_modules/@esbuild/freebsd-arm64": {
- "version": "0.25.11",
- "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.11.tgz",
- "integrity": "sha512-CmKjrnayyTJF2eVuO//uSjl/K3KsMIeYeyN7FyDBjsR3lnSJHaXlVoAK8DZa7lXWChbuOk7NjAc7ygAwrnPBhA==",
- "cpu": [
- "arm64"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "freebsd"
- ],
- "engines": {
- "node": ">=18"
- }
- },
- "node_modules/@esbuild/freebsd-x64": {
- "version": "0.25.11",
- "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.11.tgz",
- "integrity": "sha512-Dyq+5oscTJvMaYPvW3x3FLpi2+gSZTCE/1ffdwuM6G1ARang/mb3jvjxs0mw6n3Lsw84ocfo9CrNMqc5lTfGOw==",
- "cpu": [
- "x64"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "freebsd"
- ],
- "engines": {
- "node": ">=18"
- }
- },
- "node_modules/@esbuild/linux-arm": {
- "version": "0.25.11",
- "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.11.tgz",
- "integrity": "sha512-TBMv6B4kCfrGJ8cUPo7vd6NECZH/8hPpBHHlYI3qzoYFvWu2AdTvZNuU/7hsbKWqu/COU7NIK12dHAAqBLLXgw==",
- "cpu": [
- "arm"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "linux"
- ],
- "engines": {
- "node": ">=18"
- }
- },
- "node_modules/@esbuild/linux-arm64": {
- "version": "0.25.11",
- "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.11.tgz",
- "integrity": "sha512-Qr8AzcplUhGvdyUF08A1kHU3Vr2O88xxP0Tm8GcdVOUm25XYcMPp2YqSVHbLuXzYQMf9Bh/iKx7YPqECs6ffLA==",
- "cpu": [
- "arm64"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "linux"
- ],
- "engines": {
- "node": ">=18"
- }
- },
- "node_modules/@esbuild/linux-ia32": {
- "version": "0.25.11",
- "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.11.tgz",
- "integrity": "sha512-TmnJg8BMGPehs5JKrCLqyWTVAvielc615jbkOirATQvWWB1NMXY77oLMzsUjRLa0+ngecEmDGqt5jiDC6bfvOw==",
- "cpu": [
- "ia32"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "linux"
- ],
- "engines": {
- "node": ">=18"
- }
- },
- "node_modules/@esbuild/linux-loong64": {
- "version": "0.25.11",
- "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.11.tgz",
- "integrity": "sha512-DIGXL2+gvDaXlaq8xruNXUJdT5tF+SBbJQKbWy/0J7OhU8gOHOzKmGIlfTTl6nHaCOoipxQbuJi7O++ldrxgMw==",
- "cpu": [
- "loong64"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "linux"
- ],
- "engines": {
- "node": ">=18"
- }
- },
- "node_modules/@esbuild/linux-mips64el": {
- "version": "0.25.11",
- "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.11.tgz",
- "integrity": "sha512-Osx1nALUJu4pU43o9OyjSCXokFkFbyzjXb6VhGIJZQ5JZi8ylCQ9/LFagolPsHtgw6himDSyb5ETSfmp4rpiKQ==",
- "cpu": [
- "mips64el"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "linux"
- ],
- "engines": {
- "node": ">=18"
- }
- },
- "node_modules/@esbuild/linux-ppc64": {
- "version": "0.25.11",
- "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.11.tgz",
- "integrity": "sha512-nbLFgsQQEsBa8XSgSTSlrnBSrpoWh7ioFDUmwo158gIm5NNP+17IYmNWzaIzWmgCxq56vfr34xGkOcZ7jX6CPw==",
- "cpu": [
- "ppc64"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "linux"
- ],
- "engines": {
- "node": ">=18"
- }
- },
- "node_modules/@esbuild/linux-riscv64": {
- "version": "0.25.11",
- "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.11.tgz",
- "integrity": "sha512-HfyAmqZi9uBAbgKYP1yGuI7tSREXwIb438q0nqvlpxAOs3XnZ8RsisRfmVsgV486NdjD7Mw2UrFSw51lzUk1ww==",
- "cpu": [
- "riscv64"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "linux"
- ],
- "engines": {
- "node": ">=18"
- }
- },
- "node_modules/@esbuild/linux-s390x": {
- "version": "0.25.11",
- "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.11.tgz",
- "integrity": "sha512-HjLqVgSSYnVXRisyfmzsH6mXqyvj0SA7pG5g+9W7ESgwA70AXYNpfKBqh1KbTxmQVaYxpzA/SvlB9oclGPbApw==",
- "cpu": [
- "s390x"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "linux"
- ],
- "engines": {
- "node": ">=18"
- }
- },
- "node_modules/@esbuild/linux-x64": {
- "version": "0.25.11",
- "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.11.tgz",
- "integrity": "sha512-HSFAT4+WYjIhrHxKBwGmOOSpphjYkcswF449j6EjsjbinTZbp8PJtjsVK1XFJStdzXdy/jaddAep2FGY+wyFAQ==",
- "cpu": [
- "x64"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "linux"
- ],
- "engines": {
- "node": ">=18"
- }
- },
- "node_modules/@esbuild/netbsd-arm64": {
- "version": "0.25.11",
- "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.11.tgz",
- "integrity": "sha512-hr9Oxj1Fa4r04dNpWr3P8QKVVsjQhqrMSUzZzf+LZcYjZNqhA3IAfPQdEh1FLVUJSiu6sgAwp3OmwBfbFgG2Xg==",
- "cpu": [
- "arm64"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "netbsd"
- ],
- "engines": {
- "node": ">=18"
- }
- },
- "node_modules/@esbuild/netbsd-x64": {
- "version": "0.25.11",
- "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.11.tgz",
- "integrity": "sha512-u7tKA+qbzBydyj0vgpu+5h5AeudxOAGncb8N6C9Kh1N4n7wU1Xw1JDApsRjpShRpXRQlJLb9wY28ELpwdPcZ7A==",
- "cpu": [
- "x64"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "netbsd"
- ],
- "engines": {
- "node": ">=18"
- }
- },
- "node_modules/@esbuild/openbsd-arm64": {
- "version": "0.25.11",
- "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.11.tgz",
- "integrity": "sha512-Qq6YHhayieor3DxFOoYM1q0q1uMFYb7cSpLD2qzDSvK1NAvqFi8Xgivv0cFC6J+hWVw2teCYltyy9/m/14ryHg==",
- "cpu": [
- "arm64"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "openbsd"
- ],
- "engines": {
- "node": ">=18"
- }
- },
- "node_modules/@esbuild/openbsd-x64": {
- "version": "0.25.11",
- "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.11.tgz",
- "integrity": "sha512-CN+7c++kkbrckTOz5hrehxWN7uIhFFlmS/hqziSFVWpAzpWrQoAG4chH+nN3Be+Kzv/uuo7zhX716x3Sn2Jduw==",
- "cpu": [
- "x64"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "openbsd"
- ],
- "engines": {
- "node": ">=18"
- }
- },
- "node_modules/@esbuild/openharmony-arm64": {
- "version": "0.25.11",
- "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.25.11.tgz",
- "integrity": "sha512-rOREuNIQgaiR+9QuNkbkxubbp8MSO9rONmwP5nKncnWJ9v5jQ4JxFnLu4zDSRPf3x4u+2VN4pM4RdyIzDty/wQ==",
- "cpu": [
- "arm64"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "openharmony"
- ],
- "engines": {
- "node": ">=18"
- }
- },
- "node_modules/@esbuild/sunos-x64": {
- "version": "0.25.11",
- "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.11.tgz",
- "integrity": "sha512-nq2xdYaWxyg9DcIyXkZhcYulC6pQ2FuCgem3LI92IwMgIZ69KHeY8T4Y88pcwoLIjbed8n36CyKoYRDygNSGhA==",
- "cpu": [
- "x64"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "sunos"
- ],
- "engines": {
- "node": ">=18"
- }
- },
- "node_modules/@esbuild/win32-arm64": {
- "version": "0.25.11",
- "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.11.tgz",
- "integrity": "sha512-3XxECOWJq1qMZ3MN8srCJ/QfoLpL+VaxD/WfNRm1O3B4+AZ/BnLVgFbUV3eiRYDMXetciH16dwPbbHqwe1uU0Q==",
- "cpu": [
- "arm64"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "win32"
- ],
- "engines": {
- "node": ">=18"
- }
- },
- "node_modules/@esbuild/win32-ia32": {
- "version": "0.25.11",
- "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.11.tgz",
- "integrity": "sha512-3ukss6gb9XZ8TlRyJlgLn17ecsK4NSQTmdIXRASVsiS2sQ6zPPZklNJT5GR5tE/MUarymmy8kCEf5xPCNCqVOA==",
- "cpu": [
- "ia32"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "win32"
- ],
- "engines": {
- "node": ">=18"
- }
- },
- "node_modules/@esbuild/win32-x64": {
- "version": "0.25.11",
- "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.11.tgz",
- "integrity": "sha512-D7Hpz6A2L4hzsRpPaCYkQnGOotdUpDzSGRIv9I+1ITdHROSFUWW95ZPZWQmGka1Fg7W3zFJowyn9WGwMJ0+KPA==",
- "cpu": [
- "x64"
- ],
- "license": "MIT",
- "optional": true,
- "os": [
- "win32"
- ],
- "engines": {
- "node": ">=18"
- }
- },
- "node_modules/@types/node": {
- "version": "20.19.24",
- "resolved": "https://registry.npmjs.org/@types/node/-/node-20.19.24.tgz",
- "integrity": "sha512-FE5u0ezmi6y9OZEzlJfg37mqqf6ZDSF2V/NLjUyGrR9uTZ7Sb9F7bLNZ03S4XVUNRWGA7Ck4c1kK+YnuWjl+DA==",
- "license": "MIT",
- "dependencies": {
- "undici-types": "~6.21.0"
- }
- },
- "node_modules/esbuild": {
- "version": "0.25.11",
- "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.11.tgz",
- "integrity": "sha512-KohQwyzrKTQmhXDW1PjCv3Tyspn9n5GcY2RTDqeORIdIJY8yKIF7sTSopFmn/wpMPW4rdPXI0UE5LJLuq3bx0Q==",
- "hasInstallScript": true,
- "license": "MIT",
- "bin": {
- "esbuild": "bin/esbuild"
- },
- "engines": {
- "node": ">=18"
- },
- "optionalDependencies": {
- "@esbuild/aix-ppc64": "0.25.11",
- "@esbuild/android-arm": "0.25.11",
- "@esbuild/android-arm64": "0.25.11",
- "@esbuild/android-x64": "0.25.11",
- "@esbuild/darwin-arm64": "0.25.11",
- "@esbuild/darwin-x64": "0.25.11",
- "@esbuild/freebsd-arm64": "0.25.11",
- "@esbuild/freebsd-x64": "0.25.11",
- "@esbuild/linux-arm": "0.25.11",
- "@esbuild/linux-arm64": "0.25.11",
- "@esbuild/linux-ia32": "0.25.11",
- "@esbuild/linux-loong64": "0.25.11",
- "@esbuild/linux-mips64el": "0.25.11",
- "@esbuild/linux-ppc64": "0.25.11",
- "@esbuild/linux-riscv64": "0.25.11",
- "@esbuild/linux-s390x": "0.25.11",
- "@esbuild/linux-x64": "0.25.11",
- "@esbuild/netbsd-arm64": "0.25.11",
- "@esbuild/netbsd-x64": "0.25.11",
- "@esbuild/openbsd-arm64": "0.25.11",
- "@esbuild/openbsd-x64": "0.25.11",
- "@esbuild/openharmony-arm64": "0.25.11",
- "@esbuild/sunos-x64": "0.25.11",
- "@esbuild/win32-arm64": "0.25.11",
- "@esbuild/win32-ia32": "0.25.11",
- "@esbuild/win32-x64": "0.25.11"
- }
- },
- "node_modules/fsevents": {
- "version": "2.3.3",
- "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
- "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
- "hasInstallScript": true,
- "license": "MIT",
- "optional": true,
- "os": [
- "darwin"
- ],
- "engines": {
- "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
- }
- },
- "node_modules/get-tsconfig": {
- "version": "4.13.0",
- "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.13.0.tgz",
- "integrity": "sha512-1VKTZJCwBrvbd+Wn3AOgQP/2Av+TfTCOlE4AcRJE72W1ksZXbAx8PPBR9RzgTeSPzlPMHrbANMH3LbltH73wxQ==",
- "license": "MIT",
- "dependencies": {
- "resolve-pkg-maps": "^1.0.0"
- },
- "funding": {
- "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1"
- }
- },
- "node_modules/resolve-pkg-maps": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz",
- "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==",
- "license": "MIT",
- "funding": {
- "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1"
- }
- },
- "node_modules/tsx": {
- "version": "4.20.6",
- "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.20.6.tgz",
- "integrity": "sha512-ytQKuwgmrrkDTFP4LjR0ToE2nqgy886GpvRSpU0JAnrdBYppuY5rLkRUYPU1yCryb24SsKBTL/hlDQAEFVwtZg==",
- "license": "MIT",
- "dependencies": {
- "esbuild": "~0.25.0",
- "get-tsconfig": "^4.7.5"
- },
- "bin": {
- "tsx": "dist/cli.mjs"
- },
- "engines": {
- "node": ">=18.0.0"
- },
- "optionalDependencies": {
- "fsevents": "~2.3.3"
- }
- },
- "node_modules/typescript": {
- "version": "5.9.3",
- "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
- "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
- "license": "Apache-2.0",
- "bin": {
- "tsc": "bin/tsc",
- "tsserver": "bin/tsserver"
- },
- "engines": {
- "node": ">=14.17"
- }
- },
- "node_modules/undici-types": {
- "version": "6.21.0",
- "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
- "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
- "license": "MIT"
- }
- }
-}
diff --git a/.claude/hooks/package.json b/.claude/hooks/package.json
deleted file mode 100644
index c462606b76..0000000000
--- a/.claude/hooks/package.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "name": "claude-hooks",
- "version": "1.0.0",
- "description": "TypeScript hooks for Claude Code skill auto-activation",
- "private": true,
- "type": "module",
- "scripts": {
- "check": "tsc --noEmit",
- "test": "tsx skill-activation-prompt.ts < test-input.json"
- },
- "dependencies": {
- "@types/node": "^20.11.0",
- "tsx": "^4.7.0",
- "typescript": "^5.3.3"
- }
-}
diff --git a/.claude/hooks/post-tool-use-tracker.sh b/.claude/hooks/post-tool-use-tracker.sh
deleted file mode 100755
index dcc2b68147..0000000000
--- a/.claude/hooks/post-tool-use-tracker.sh
+++ /dev/null
@@ -1,170 +0,0 @@
-#!/bin/bash
-set -e
-
-# Post-tool-use hook that tracks edited files and their repos
-# This runs after Edit, MultiEdit, or Write tools complete successfully
-
-
-# Read tool information from stdin
-tool_info=$(cat)
-
-
-# Extract relevant data
-tool_name=$(echo "$tool_info" | jq -r '.tool_name // empty')
-file_path=$(echo "$tool_info" | jq -r '.tool_input.file_path // empty')
-session_id=$(echo "$tool_info" | jq -r '.session_id // empty')
-
-
-# Skip if not an edit tool or no file path
-if [[ ! "$tool_name" =~ ^(Edit|MultiEdit|Write)$ ]] || [[ -z "$file_path" ]]; then
- exit 0 # Exit 0 for skip conditions
-fi
-
-# Skip markdown files
-if [[ "$file_path" =~ \.(md|markdown)$ ]]; then
- exit 0 # Exit 0 for skip conditions
-fi
-
-# Create cache directory in project
-cache_dir="$CLAUDE_PROJECT_DIR/.claude/tsc-cache/${session_id:-default}"
-mkdir -p "$cache_dir"
-
-# Function to detect repo from file path
-detect_repo() {
- local file="$1"
- local project_root="$CLAUDE_PROJECT_DIR"
-
- # Remove project root from path
- local relative_path="${file#$project_root/}"
-
- # Extract first directory component
- local repo=$(echo "$relative_path" | cut -d'/' -f1)
-
- # Common project directory patterns
- case "$repo" in
- # Frontend variations
- frontend|client|web|app|ui)
- echo "$repo"
- ;;
- # Backend variations
- backend|server|api|src|services|worker)
- echo "$repo"
- ;;
- # Database
- database|prisma|migrations)
- echo "$repo"
- ;;
- # Package/monorepo structure
- packages)
- # For monorepos, get the package name
- local package=$(echo "$relative_path" | cut -d'/' -f2)
- if [[ -n "$package" ]]; then
- echo "packages/$package"
- else
- echo "$repo"
- fi
- ;;
- # Default case
- *)
- # Check if it's a source file in root
- if [[ ! "$relative_path" =~ / ]]; then
- echo "root"
- else
- echo "unknown"
- fi
- ;;
- esac
-}
-
-# Function to get build command for repo
-get_build_command() {
- local repo="$1"
- local project_root="$CLAUDE_PROJECT_DIR"
- local repo_path="$project_root/$repo"
-
- # Check if package.json exists and has a build script
- if [[ -f "$repo_path/package.json" ]]; then
- if grep -q '"build"' "$repo_path/package.json" 2>/dev/null; then
- # Detect package manager (prefer pnpm, then npm, then yarn)
- if [[ -f "$repo_path/pnpm-lock.yaml" ]]; then
- echo "cd $repo_path && pnpm build"
- elif [[ -f "$repo_path/package-lock.json" ]]; then
- echo "cd $repo_path && npm run build"
- elif [[ -f "$repo_path/yarn.lock" ]]; then
- echo "cd $repo_path && yarn build"
- else
- echo "cd $repo_path && npm run build"
- fi
- return
- fi
- fi
-
- # Special case for database with Prisma
- if [[ "$repo" == "database" ]] || [[ "$repo" =~ prisma ]]; then
- if [[ -f "$repo_path/schema.prisma" ]] || [[ -f "$repo_path/prisma/schema.prisma" ]]; then
- echo "cd $repo_path && npx prisma generate"
- return
- fi
- fi
-
- # No build command found
- echo ""
-}
-
-# Function to get TSC command for repo
-get_tsc_command() {
- local repo="$1"
- local project_root="$CLAUDE_PROJECT_DIR"
- local repo_path="$project_root/$repo"
-
- # Check if tsconfig.json exists
- if [[ -f "$repo_path/tsconfig.json" ]]; then
- # Check for Vite/React-specific tsconfig
- if [[ -f "$repo_path/tsconfig.app.json" ]]; then
- echo "cd $repo_path && npx tsc --project tsconfig.app.json --noEmit"
- else
- echo "cd $repo_path && npx tsc --noEmit"
- fi
- return
- fi
-
- # No TypeScript config found
- echo ""
-}
-
-# Detect repo
-repo=$(detect_repo "$file_path")
-
-# Skip if unknown repo
-if [[ "$repo" == "unknown" ]] || [[ -z "$repo" ]]; then
- exit 0 # Exit 0 for skip conditions
-fi
-
-# Log edited file
-echo "$(date +%s):$file_path:$repo" >> "$cache_dir/edited-files.log"
-
-# Update affected repos list
-if ! grep -q "^$repo$" "$cache_dir/affected-repos.txt" 2>/dev/null; then
- echo "$repo" >> "$cache_dir/affected-repos.txt"
-fi
-
-# Store build commands
-build_cmd=$(get_build_command "$repo")
-tsc_cmd=$(get_tsc_command "$repo")
-
-if [[ -n "$build_cmd" ]]; then
- echo "$repo:build:$build_cmd" >> "$cache_dir/commands.txt.tmp"
-fi
-
-if [[ -n "$tsc_cmd" ]]; then
- echo "$repo:tsc:$tsc_cmd" >> "$cache_dir/commands.txt.tmp"
-fi
-
-# Remove duplicates from commands
-if [[ -f "$cache_dir/commands.txt.tmp" ]]; then
- sort -u "$cache_dir/commands.txt.tmp" > "$cache_dir/commands.txt"
- rm -f "$cache_dir/commands.txt.tmp"
-fi
-
-# Exit cleanly
-exit 0
diff --git a/.claude/hooks/skill-activation-prompt.sh b/.claude/hooks/skill-activation-prompt.sh
deleted file mode 100755
index fe594c9e60..0000000000
--- a/.claude/hooks/skill-activation-prompt.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-set -e
-
-cd "$CLAUDE_PROJECT_DIR/.claude/hooks"
-cat | npx tsx skill-activation-prompt.ts
diff --git a/.claude/hooks/skill-activation-prompt.ts b/.claude/hooks/skill-activation-prompt.ts
deleted file mode 100644
index 3eb045555e..0000000000
--- a/.claude/hooks/skill-activation-prompt.ts
+++ /dev/null
@@ -1,136 +0,0 @@
-#!/usr/bin/env node
-import { readFileSync } from "fs";
-import { join } from "path";
-
-interface HookInput {
- session_id: string;
- transcript_path: string;
- cwd: string;
- permission_mode: string;
- prompt: string;
-}
-
-interface PromptTriggers {
- keywords?: string[];
- intentPatterns?: string[];
-}
-
-interface SkillRule {
- type: "guardrail" | "domain";
- enforcement: "block" | "suggest" | "warn";
- priority: "critical" | "high" | "medium" | "low";
- promptTriggers?: PromptTriggers;
-}
-
-interface SkillRules {
- version: string;
- skills: Record<string, SkillRule>;
-}
-
-interface MatchedSkill {
- name: string;
- matchType: "keyword" | "intent";
- config: SkillRule;
-}
-
-async function main() {
- try {
- // Read input from stdin
- const input = readFileSync(0, "utf-8");
- const data: HookInput = JSON.parse(input);
- const prompt = data.prompt.toLowerCase();
-
- // Load skill rules
- const projectDir = process.env.CLAUDE_PROJECT_DIR || "$HOME/project";
- const rulesPath = join(projectDir, ".claude", "skills", "skill-rules.json");
- const rules: SkillRules = JSON.parse(readFileSync(rulesPath, "utf-8"));
-
- const matchedSkills: MatchedSkill[] = [];
-
- // Check each skill for matches
- for (const [skillName, config] of Object.entries(rules.skills)) {
- const triggers = config.promptTriggers;
- if (!triggers) {
- continue;
- }
-
- // Keyword matching
- if (triggers.keywords) {
- const keywordMatch = triggers.keywords.some((kw) =>
- prompt.includes(kw.toLowerCase()),
- );
- if (keywordMatch) {
- matchedSkills.push({ name: skillName, matchType: "keyword", config });
- continue;
- }
- }
-
- // Intent pattern matching
- if (triggers.intentPatterns) {
- const intentMatch = triggers.intentPatterns.some((pattern) => {
- const regex = new RegExp(pattern, "i");
- return regex.test(prompt);
- });
- if (intentMatch) {
- matchedSkills.push({ name: skillName, matchType: "intent", config });
- }
- }
- }
-
- // Generate output if matches found
- if (matchedSkills.length > 0) {
- let output = "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
- output += "🎯 SKILL ACTIVATION CHECK\n";
- output += "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n";
-
- // Group by priority
- const critical = matchedSkills.filter(
- (s) => s.config.priority === "critical",
- );
- const high = matchedSkills.filter((s) => s.config.priority === "high");
- const medium = matchedSkills.filter(
- (s) => s.config.priority === "medium",
- );
- const low = matchedSkills.filter((s) => s.config.priority === "low");
-
- if (critical.length > 0) {
- output += "⚠️ CRITICAL SKILLS (REQUIRED):\n";
- critical.forEach((s) => (output += ` β†’ ${s.name}\n`));
- output += "\n";
- }
-
- if (high.length > 0) {
- output += "πŸ“š RECOMMENDED SKILLS:\n";
- high.forEach((s) => (output += ` β†’ ${s.name}\n`));
- output += "\n";
- }
-
- if (medium.length > 0) {
- output += "πŸ’‘ SUGGESTED SKILLS:\n";
- medium.forEach((s) => (output += ` β†’ ${s.name}\n`));
- output += "\n";
- }
-
- if (low.length > 0) {
- output += "πŸ“Œ OPTIONAL SKILLS:\n";
- low.forEach((s) => (output += ` β†’ ${s.name}\n`));
- output += "\n";
- }
-
- output += "ACTION: Use Skill tool BEFORE responding\n";
- output += "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
-
- console.log(output);
- }
-
- process.exit(0);
- } catch (err) {
- console.error("Error in skill-activation-prompt hook:", err);
- process.exit(1);
- }
-}
-
-main().catch((err) => {
- console.error("Uncaught error:", err);
- process.exit(1);
-});
diff --git a/.claude/hooks/tsconfig.json b/.claude/hooks/tsconfig.json
deleted file mode 100644
index b9df89f1e7..0000000000
--- a/.claude/hooks/tsconfig.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "compilerOptions": {
- "target": "ES2022",
- "module": "NodeNext",
- "moduleResolution": "NodeNext",
- "lib": ["ES2022"],
- "outDir": "./dist",
- "rootDir": ".",
- "strict": true,
- "esModuleInterop": true,
- "skipLibCheck": true,
- "forceConsistentCasingInFileNames": true,
- "resolveJsonModule": true,
- "allowSyntheticDefaultImports": true,
- "types": ["node"]
- },
- "include": ["*.ts"],
- "exclude": ["node_modules", "dist"]
-}
diff --git a/.claude/settings.json b/.claude/settings.json
index 989ad28b95..4b765f346f 100644
--- a/.claude/settings.json
+++ b/.claude/settings.json
@@ -12,28 +12,5 @@
"deny": []
},
"enableAllProjectMcpServers": true,
- "enabledMcpjsonServers": ["sequential-thinking"],
- "hooks": {
- "UserPromptSubmit": [
- {
- "hooks": [
- {
- "type": "command",
- "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/skill-activation-prompt.sh"
- }
- ]
- }
- ],
- "PostToolUse": [
- {
- "matcher": "Edit|MultiEdit|Write",
- "hooks": [
- {
- "type": "command",
- "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/post-tool-use-tracker.sh"
- }
- ]
- }
- ]
- }
+ "enabledMcpjsonServers": ["sequential-thinking"]
}
diff --git a/.claude/skills/README.md b/.claude/skills/README.md
index ac992ab483..b5be803d80 100644
--- a/.claude/skills/README.md
+++ b/.claude/skills/README.md
@@ -1,304 +1,6 @@
-# Skills
+# Claude Skills
-Production-tested skills for Claude Code that auto-activate based on context.
+Shared repo skills now live in [`.agents/skills/README.md`](../../.agents/skills/README.md).
----
-
-## What Are Skills?
-
-Skills are modular knowledge bases that Claude loads when needed. They provide:
-
-- Domain-specific guidelines
-- Best practices
-- Code examples
-- Anti-patterns to avoid
-
-**Problem:** Skills don't activate automatically by default.
-
-**Solution:** This showcase includes the hooks + configuration to make them activate.
-
----
-
-## Available Skills
-
-### skill-developer (Meta-Skill)
-
-**Purpose:** Creating and managing Claude Code skills
-
-**Files:** 7 resource files (426 lines total)
-
-**Use when:**
-
-- Creating new skills
-- Understanding skill structure
-- Working with skill-rules.json
-- Debugging skill activation
-
-**Customization:** βœ… None - copy as-is
-
-**[View Skill β†’](skill-developer/)**
-
----
-
-### backend-dev-guidelines
-
-**Purpose:** Node.js/Express/TypeScript development patterns
-
-**Files:** 12 resource files (304 lines main + resources)
-
-**Covers:**
-
-- Layered architecture (Routes β†’ Controllers β†’ Services β†’ Repositories)
-- BaseController pattern
-- Prisma database access
-- Sentry error tracking
-- Zod validation
-- UnifiedConfig pattern
-- Dependency injection
-- Testing strategies
-
-**Use when:**
-
-- Creating/modifying API routes
-- Building controllers or services
-- Database operations with Prisma
-- Setting up error tracking
-
-**Customization:** ⚠️ Update `pathPatterns` in skill-rules.json to match your backend directories
-
-**Example pathPatterns:**
-
-```json
-{
- "pathPatterns": [
- "src/api/**/*.ts", // Single app with src/api
- "backend/**/*.ts", // Backend directory
- "services/*/src/**/*.ts" // Multi-service monorepo
- ]
-}
-```
-
-**[View Skill β†’](backend-dev-guidelines/)**
-
----
-
-## How to Add a Skill to Your Project
-
-### Quick Integration
-
-**For Claude Code:**
-
-```
-User: "Add the backend-dev-guidelines skill to my project"
-
-Claude should:
-1. Ask about project structure
-2. Copy skill directory
-3. Update skill-rules.json with their paths
-4. Verify integration
-```
-
-See [CLAUDE_INTEGRATION_GUIDE.md](../../CLAUDE_INTEGRATION_GUIDE.md) for complete instructions.
-
-### Manual Integration
-
-**Step 1: Copy the skill directory**
-
-```bash
-cp -r claude-code-infrastructure-showcase/.claude/skills/backend-dev-guidelines \\
- your-project/.claude/skills/
-```
-
-**Step 2: Update skill-rules.json**
-
-If you don't have one, create it:
-
-```bash
-cp claude-code-infrastructure-showcase/.claude/skills/skill-rules.json \\
- your-project/.claude/skills/
-```
-
-Then customize the `pathPatterns` for your project:
-
-```json
-{
- "skills": {
- "backend-dev-guidelines": {
- "fileTriggers": {
- "pathPatterns": [
- "YOUR_BACKEND_PATH/**/*.ts" // ← Update this!
- ]
- }
- }
- }
-}
-```
-
-**Step 3: Test**
-
-- Edit a file in your backend directory
-- The skill should activate automatically
-
----
-
-## skill-rules.json Configuration
-
-### What It Does
-
-Defines when skills should activate based on:
-
-- **Keywords** in user prompts ("backend", "API", "route")
-- **Intent patterns** (regex matching user intent)
-- **File path patterns** (editing backend files)
-- **Content patterns** (code contains Prisma queries)
-
-### Configuration Format
-
-```json
-{
- "skill-name": {
- "type": "domain" | "guardrail",
- "enforcement": "suggest" | "block",
- "priority": "high" | "medium" | "low",
- "promptTriggers": {
- "keywords": ["list", "of", "keywords"],
- "intentPatterns": ["regex patterns"]
- },
- "fileTriggers": {
- "pathPatterns": ["path/to/files/**/*.ts"],
- "contentPatterns": ["import.*Prisma"]
- }
- }
-}
-```
-
-### Enforcement Levels
-
-- **suggest**: Skill appears as suggestion, doesn't block
-- **block**: Must use skill before proceeding (guardrail)
-
-**Use "block" for:**
-
-- Preventing breaking changes (MUI v6β†’v7)
-- Critical database operations
-- Security-sensitive code
-
-**Use "suggest" for:**
-
-- General best practices
-- Domain guidance
-- Code organization
-
----
-
-## Creating Your Own Skills
-
-See the **skill-developer** skill for complete guide on:
-
-- Skill YAML frontmatter structure
-- Resource file organization
-- Trigger pattern design
-- Testing skill activation
-
-**Quick template:**
-
-```markdown
----
-name: my-skill
-description: What this skill does
----
-
-# My Skill Title
-
-## Purpose
-
-[Why this skill exists]
-
-## When to Use This Skill
-
-[Auto-activation scenarios]
-
-## Quick Reference
-
-[Key patterns and examples]
-
-## Resource Files
-
-- [topic-1.md](resources/topic-1.md)
-- [topic-2.md](resources/topic-2.md)
-```
-
----
-
-## Troubleshooting
-
-### Skill isn't activating
-
-**Check:**
-
-1. Is skill directory in `.claude/skills/`?
-2. Is skill listed in `skill-rules.json`?
-3. Do `pathPatterns` match your files?
-4. Are hooks installed and working?
-5. Is settings.json configured correctly?
-
-**Debug:**
-
-```bash
-# Check skill exists
-ls -la .claude/skills/
-
-# Validate skill-rules.json
-cat .claude/skills/skill-rules.json | jq .
-
-# Check hooks are executable
-ls -la .claude/hooks/*.sh
-
-# Test hook manually
-./.claude/hooks/skill-activation-prompt.sh
-```
-
-### Skill activates too often
-
-Update skill-rules.json:
-
-- Make keywords more specific
-- Narrow `pathPatterns`
-- Increase specificity of `intentPatterns`
-
-### Skill never activates
-
-Update skill-rules.json:
-
-- Add more keywords
-- Broaden `pathPatterns`
-- Add more `intentPatterns`
-
----
-
-## For Claude Code
-
-**When integrating a skill for a user:**
-
-1. **Read [CLAUDE_INTEGRATION_GUIDE.md](../../CLAUDE_INTEGRATION_GUIDE.md)** first
-2. Ask about their project structure
-3. Customize `pathPatterns` in skill-rules.json
-4. Verify the skill file has no hardcoded paths
-5. Test activation after integration
-
-**Common mistakes:**
-
-- Keeping example paths (blog-api/, frontend/)
-- Not asking about monorepo vs single-app
-- Copying skill-rules.json without customization
-
----
-
-## Next Steps
-
-1. **Start simple:** Add one skill that matches your work
-2. **Verify activation:** Edit a relevant file, skill should suggest
-3. **Add more:** Once first skill works, add others
-4. **Customize:** Adjust triggers based on your workflow
-
-**Questions?** See [CLAUDE_INTEGRATION_GUIDE.md](../../CLAUDE_INTEGRATION_GUIDE.md) for comprehensive integration instructions.
+Use `CLAUDE.md` to point Claude Code at those neutral skill files with `@`
+imports. Keep tool-independent skill content under `.agents/skills/`.
diff --git a/.claude/skills/add-model-price/SKILL.md b/.claude/skills/add-model-price/SKILL.md
deleted file mode 100644
index 2c3aa5b6b9..0000000000
--- a/.claude/skills/add-model-price/SKILL.md
+++ /dev/null
@@ -1,524 +0,0 @@
----
-name: add-model-price
-description: Add new LLM model pricing entries to Langfuse's default-model-prices.json. Use when adding model prices, updating model pricing, creating model entries, adding Claude/OpenAI/Anthropic/Google/Gemini/AWS Bedrock/Azure/Vertex AI model pricing, working with matchPattern regex, pricingTiers, or model cost configuration. Covers model price JSON structure, regex patterns for multi-provider matching, tiered pricing with conditions, cache pricing, and validation rules.
----
-
-# Add Model Price
-
-## Purpose
-
-Guide for adding new LLM model pricing entries to Langfuse's default model prices configuration. This enables accurate cost tracking across different model providers and deployment platforms.
-
-## When to Use This Skill
-
-Automatically activates when:
-- Adding a new model to the pricing database
-- Updating model pricing information
-- Working with `default-model-prices.json`
-- Creating model matchPattern regex
-- Configuring pricingTiers or tiered pricing
-- Adding prices for Claude, OpenAI, Anthropic, Google, Gemini, AWS Bedrock, Azure, or Vertex AI models
-
----
-
-## Quick Start Checklist
-
-### Adding a New Model
-
-- [ ] **Gather model info**: Fetch official pricing from provider documentation URL
-- [ ] **Generate UUID**: Run `uuidgen` for the model entry ID (use lowercase)
-- [ ] **Create matchPattern**: Regex covering all provider formats
-- [ ] **Define pricingTiers**: At minimum, one default tier with standard prices
-- [ ] **Add pricing entry**: Insert into `/worker/src/constants/default-model-prices.json`
-- [ ] **Add to LLM types**: Add model to `/packages/shared/src/server/llm/types.ts` (for playground/LLM-as-judge)
-- [ ] **Validate JSON**: Run `jq . default-model-prices.json` to verify syntax
-
-### Updating an Existing Model
-
-- [ ] **Modify the entry**: Update prices, add new usage type keys, etc.
-- [ ] **Update `updatedAt`**: Set to today's date in ISO-8601 format (e.g., `"2026-03-04T00:00:00.000Z"`)
-- [ ] **Validate JSON**: Run `jq . default-model-prices.json` to verify syntax
-
----
-
-## File Location
-
-**Target File**: `/worker/src/constants/default-model-prices.json`
-
-This JSON file contains an array of model pricing definitions used for cost calculation.
-
----
-
-## Data Structure
-
-### Complete Model Entry Schema
-
-```json
-{
- "id": "uuid-generated-with-uuidgen",
- "modelName": "model-name-identifier",
- "matchPattern": "(?i)^regex-pattern$",
- "createdAt": "ISO-8601-timestamp",
- "updatedAt": "ISO-8601-timestamp",
- "tokenizerConfig": null,
- "tokenizerId": "claude|openai|null",
- "pricingTiers": [
- {
- "id": "model-uuid_tier_default",
- "name": "Standard",
- "isDefault": true,
- "priority": 0,
- "conditions": [],
- "prices": {
- "input": 0.000005,
- "output": 0.000025
- }
- }
- ]
-}
-```
-
-### Required Fields
-
-| Field | Type | Description |
-|-------|------|-------------|
-| `id` | string | Unique UUID (use `uuidgen` command, lowercase) |
-| `modelName` | string | Primary model identifier |
-| `matchPattern` | string | Regex for matching model names |
-| `createdAt` | string | ISO-8601 timestamp (set once on creation) |
-| `updatedAt` | string | ISO-8601 timestamp (**must be updated to today's date whenever the entry is modified**) |
-| `pricingTiers` | array | At least one pricing tier |
-
-### Optional Fields
-
-| Field | Type | Default | Description |
-|-------|------|---------|-------------|
-| `tokenizerId` | string | null | "claude", "openai", or null |
-| `tokenizerConfig` | object | null | Custom tokenizer settings |
-
----
-
-## Pricing Tier Structure
-
-### Default Tier (Required)
-
-Every model must have exactly one default tier:
-
-```json
-{
- "id": "{model-id}_tier_default",
- "name": "Standard",
- "isDefault": true,
- "priority": 0,
- "conditions": [],
- "prices": { }
-}
-```
-
-**Rules for Default Tier:**
-- `isDefault`: Must be `true`
-- `priority`: Must be `0`
-- `conditions`: Must be empty array `[]`
-
-### Additional Tiers (Optional)
-
-For usage-based pricing (e.g., large context pricing):
-
-```json
-{
- "id": "uuid-for-tier",
- "name": "Large Context (>200K)",
- "isDefault": false,
- "priority": 1,
- "conditions": [
- {
- "usageDetailPattern": "(input|prompt|cached)",
- "operator": "gt",
- "value": 200000,
- "caseSensitive": false
- }
- ],
- "prices": { }
-}
-```
-
-**Condition Operators:** `gt`, `gte`, `lt`, `lte`, `eq`, `neq`
-
----
-
-## Gathering Pricing Information
-
-**IMPORTANT**: Always fetch pricing from official provider documentation. Never use heuristics or assumptions.
-
-### Official Pricing Sources
-
-| Provider | URL |
-|----------|-----|
-| Anthropic Claude | https://platform.claude.com/docs/en/about-claude/pricing |
-| OpenAI | https://openai.com/api/pricing/ |
-| Google Gemini | https://ai.google.dev/pricing |
-| AWS Bedrock | https://aws.amazon.com/bedrock/pricing/ |
-| Azure OpenAI | https://azure.microsoft.com/pricing/details/cognitive-services/openai-service/ |
-
-### Required Information to Gather
-
-1. **Base input token price** (per MTok)
-2. **Output token price** (per MTok)
-3. **Cache write price** (if caching supported)
-4. **Cache read price** (if caching supported)
-5. **Long context pricing** (if different tiers exist)
-6. **Model ID formats** for all platforms (API, Bedrock, Vertex)
-
----
-
-## Price Conversion
-
-Prices in the JSON are **per token**, not per million tokens.
-
-| Provider Pricing | JSON Value | Calculation |
-|-----------------|------------|-------------|
-| $5 / MTok | `5e-6` | $5 / 1,000,000 |
-| $25 / MTok | `25e-6` | $25 / 1,000,000 |
-| $0.50 / MTok | `0.5e-6` | $0.50 / 1,000,000 |
-| $6.25 / MTok | `6.25e-6` | $6.25 / 1,000,000 |
-
-**Formula**: `price_per_token = price_per_mtok / 1_000_000` or `price_per_mtok * 1e-6`
-
----
-
-## Common Price Keys by Provider
-
-### Anthropic Claude Models
-
-```json
-{
- "input": <base_input_price>,
- "input_tokens": <base_input_price>,
- "output": <output_price>,
- "output_tokens": <output_price>,
- "cache_creation_input_tokens": <cache_write_price>,
- "input_cache_creation": <cache_write_price>,
- "cache_read_input_tokens": <cache_read_price>,
- "input_cache_read": <cache_read_price>
-}
-```
-
-### OpenAI Models
-
-```json
-{
- "input": <input_price>,
- "input_cached_tokens": <cached_input_price>,
- "input_cache_read": <cached_input_price>,
- "output": <output_price>
-}
-```
-
-### Google Gemini Models
-
-```json
-{
- "input": <input_price>,
- "input_modality_1": <input_price>,
- "prompt_token_count": <input_price>,
- "promptTokenCount": <input_price>,
- "input_cached_tokens": <cached_price>,
- "cached_content_token_count": <cached_price>,
- "output": <output_price>,
- "output_modality_1": <output_price>,
- "candidates_token_count": <output_price>,
- "candidatesTokenCount": <output_price>
-}
-```
-
----
-
-## Match Pattern Examples
-
-### Anthropic Claude (API + Bedrock + Vertex)
-
-```regex
-(?i)^(anthropic\/)?(claude-opus-4-6|(eu\\.|us\\.|apac\\.)?anthropic\\.claude-opus-4-6-v1(:0)?|claude-opus-4-6)$
-```
-
-**Matches:**
-- `claude-opus-4-6` (direct API)
-- `anthropic/claude-opus-4-6` (with prefix)
-- `anthropic.claude-opus-4-6-v1:0` (AWS Bedrock)
-- `us.anthropic.claude-opus-4-6-v1:0` (regional Bedrock)
-- `claude-opus-4-6` (GCP Vertex)
-
-### With Version Date
-
-```regex
-(?i)^(anthropic\/)?(claude-opus-4-5-20251101|(eu\\.|us\\.|apac\\.)?anthropic\\.claude-opus-4-5-20251101-v1:0|claude-opus-4-5@20251101)$
-```
-
-### OpenAI
-
-```regex
-(?i)^(openai\/)?(gpt-4o)$
-```
-
-### Google Gemini
-
-```regex
-(?i)^(google\/)?(gemini-2.5-pro)$
-```
-
-### Pattern Components
-
-| Component | Purpose | Example |
-|-----------|---------|---------|
-| `(?i)` | Case insensitive | Matches GPT-4o and gpt-4o |
-| `^...$` | Full string match | Prevents partial matches |
-| `(provider\/)?` | Optional provider prefix | `openai/gpt-4o` |
-| `(eu\\.\\|us\\.\\|apac\\.)?` | AWS regions | `us.anthropic.model` |
-| `(:0)?` | Optional version suffix | Bedrock model versions |
-| `@date` | Vertex AI format | `claude-3-5-sonnet@20240620` |
-
----
-
-## Step-by-Step: Adding a New Model
-
-### Step 1: Fetch Official Pricing
-
-Use WebFetch to get pricing from official documentation:
-```
-WebFetch URL: https://platform.claude.com/docs/en/about-claude/pricing
-Prompt: Extract pricing for [model name] including input, output, cache write, cache read prices per MTok
-```
-
-### Step 2: Generate UUID
-
-```bash
-uuidgen
-# Output: 13458BC0-1C20-44C2-8753-172F54B67647
-# Convert to lowercase: 13458bc0-1c20-44c2-8753-172f54b67647
-```
-
-### Step 3: Create the Entry
-
-Example for a model with $5 input, $25 output, $6.25 cache write, $0.50 cache read:
-
-```json
-{
- "id": "13458bc0-1c20-44c2-8753-172f54b67647",
- "modelName": "claude-opus-4-6",
- "matchPattern": "(?i)^(anthropic\/)?(claude-opus-4-6|(eu\\.|us\\.|apac\\.)?anthropic\\.claude-opus-4-6-v1(:0)?|claude-opus-4-6)$",
- "createdAt": "2026-02-09T00:00:00.000Z",
- "updatedAt": "2026-02-09T00:00:00.000Z",
- "tokenizerConfig": null,
- "tokenizerId": "claude",
- "pricingTiers": [
- {
- "id": "13458bc0-1c20-44c2-8753-172f54b67647_tier_default",
- "name": "Standard",
- "isDefault": true,
- "priority": 0,
- "conditions": [],
- "prices": {
- "input": 5e-6,
- "input_tokens": 5e-6,
- "output": 25e-6,
- "output_tokens": 25e-6,
- "cache_creation_input_tokens": 6.25e-6,
- "input_cache_creation": 6.25e-6,
- "cache_read_input_tokens": 0.5e-6,
- "input_cache_read": 0.5e-6
- }
- }
- ]
-}
-```
-
-### Step 4: Insert Entry
-
-Add the entry to the JSON array in `/worker/src/constants/default-model-prices.json`.
-
-**Placement**: Insert near related models (e.g., other Claude models together).
-
-### Step 5: Add to LLM Types (for Playground & LLM-as-Judge)
-
-To make the model available in the Langfuse playground and for LLM-as-a-judge evaluations, add it to the appropriate model array in `/packages/shared/src/server/llm/types.ts`.
-
-**File**: `/packages/shared/src/server/llm/types.ts`
-
-**Model Arrays by Provider:**
-- `anthropicModels` - Anthropic Claude models
-- `openAIModels` - OpenAI GPT models
-- `vertexAIModels` - Google Vertex AI models
-- `googleAIStudioModels` - Google AI Studio models
-
-**IMPORTANT**: Do NOT add new models as the first entry in the array. The first entry is used as the default model for test LLM API calls, and newer models may not be available to all users yet.
-
-**Example for Anthropic:**
-```typescript
-export const anthropicModels = [
- "claude-sonnet-4-5-20250929", // Keep existing first entry
- "claude-haiku-4-5-20251001",
- "claude-opus-4-6", // Add new model here (not first!)
- "claude-opus-4-5-20251101",
- // ... rest of models
-] as const;
-```
-
-### Step 6: Validate
-
-```bash
-# Check JSON syntax
-jq . /path/to/default-model-prices.json > /dev/null && echo "Valid JSON"
-
-# Verify entry exists
-jq '.[] | select(.modelName == "claude-opus-4-6")' /path/to/default-model-prices.json
-```
-
----
-
-## Multi-Tier Pricing Example
-
-For models with long context pricing (e.g., different rates above 200K tokens):
-
-```json
-{
- "id": "uuid-here",
- "modelName": "model-name",
- "matchPattern": "...",
- "pricingTiers": [
- {
- "id": "uuid-here_tier_default",
- "name": "Standard",
- "isDefault": true,
- "priority": 0,
- "conditions": [],
- "prices": {
- "input": 5e-6,
- "output": 25e-6
- }
- },
- {
- "id": "uuid-for-large-context-tier",
- "name": "Large Context (>200K)",
- "isDefault": false,
- "priority": 1,
- "conditions": [
- {
- "usageDetailPattern": "(input|prompt|cached)",
- "operator": "gt",
- "value": 200000,
- "caseSensitive": false
- }
- ],
- "prices": {
- "input": 10e-6,
- "output": 37.5e-6
- }
- }
- ]
-}
-```
-
----
-
-## Validation Rules
-
-The system validates pricing tiers with these rules:
-
-1. **Exactly one default tier** with `isDefault: true`
-2. **Default tier** must have `priority: 0` and empty `conditions: []`
-3. **Non-default tiers** must have `priority > 0` and at least one condition
-4. **All priorities** must be unique within a model
-5. **All tier names** must be unique within a model
-6. **Each tier** must have at least one price
-7. **All tiers** must have identical usage type keys
-8. **Regex patterns** must be valid and safe (no catastrophic backtracking)
-
----
-
-## Common Mistakes
-
-**Using heuristics instead of official pricing:**
-```json
-// Wrong - assuming cache is 1.25x input
-"cache_creation_input_tokens": input_price * 1.25
-
-// Correct - use exact value from official docs
-"cache_creation_input_tokens": 6.25e-6
-```
-
-**Incorrect Price Format:**
-```json
-// Wrong - using MTok price directly
-"input": 5
-
-// Correct - price per token
-"input": 5e-6
-```
-
-**Missing Tier ID Suffix:**
-```json
-// Wrong
-"id": "some-uuid"
-
-// Correct for default tier
-"id": "model-uuid_tier_default"
-```
-
-**Invalid Regex Escaping:**
-```json
-// Wrong - unescaped dots
-"matchPattern": "anthropic.claude"
-
-// Correct - escaped dots
-"matchPattern": "anthropic\\.claude"
-```
-
-**Forgetting to update `updatedAt` when modifying an existing entry:**
-```json
-// Wrong - stale timestamp after modifying prices
-"updatedAt": "2025-12-12T15:00:06.513Z"
-
-// Correct - set to today's date
-"updatedAt": "2026-03-04T00:00:00.000Z"
-```
-
----
-
-## Testing Model Matching
-
-After adding a model, test that the regex matches expected inputs:
-
-```javascript
-const pattern = new RegExp(matchPattern);
-console.log(pattern.test("claude-opus-4-6")); // true
-console.log(pattern.test("anthropic/claude-opus-4-6")); // true
-console.log(pattern.test("anthropic.claude-opus-4-6-v1:0")); // true
-console.log(pattern.test("us.anthropic.claude-opus-4-6-v1:0")); // true
-```
-
----
-
-## Reference: Existing Model Entries
-
-Look at these existing entries as templates:
-
-| Model Type | Example Entry | Notes |
-|------------|---------------|-------|
-| Anthropic Claude | `claude-opus-4-5-20251101` | Full multi-provider pattern |
-| OpenAI GPT | `gpt-4o` | Simple pattern |
-| Google Gemini | `gemini-2.5-pro` | Multi-tier with large context |
-
----
-
-## Related Files
-
-- **Pricing JSON**: `/worker/src/constants/default-model-prices.json`
-- **LLM Types**: `/packages/shared/src/server/llm/types.ts` (model arrays for playground/LLM-as-judge)
-- **Validation**: `/packages/shared/src/server/pricing-tiers/validation.ts`
-- **Matcher**: `/packages/shared/src/server/pricing-tiers/matcher.ts`
-- **Tests**: `/web/src/__tests__/async/model-pricing-tiers.servertest.ts`
-
----
-
-**Skill Status**: COMPLETE
-**Line Count**: ~340 lines
diff --git a/.claude/skills/skill-developer/ADVANCED.md b/.claude/skills/skill-developer/ADVANCED.md
deleted file mode 100644
index 6395f779f2..0000000000
--- a/.claude/skills/skill-developer/ADVANCED.md
+++ /dev/null
@@ -1,197 +0,0 @@
-# Advanced Topics & Future Enhancements
-
-Ideas and concepts for future improvements to the skill system.
-
----
-
-## Dynamic Rule Updates
-
-**Current State:** Requires Claude Code restart to pick up changes to skill-rules.json
-
-**Future Enhancement:** Hot-reload configuration without restart
-
-**Implementation Ideas:**
-- Watch skill-rules.json for changes
-- Reload on file modification
-- Invalidate cached compiled regexes
-- Notify user of reload
-
-**Benefits:**
-- Faster iteration during skill development
-- No need to restart Claude Code
-- Better developer experience
-
----
-
-## Skill Dependencies
-
-**Current State:** Skills are independent
-
-**Future Enhancement:** Specify skill dependencies and load order
-
-**Configuration Idea:**
-```json
-{
- "my-advanced-skill": {
- "dependsOn": ["prerequisite-skill", "base-skill"],
- "type": "domain",
- ...
- }
-}
-```
-
-**Use Cases:**
-- Advanced skill builds on base skill knowledge
-- Ensure foundational skills loaded first
-- Chain skills for complex workflows
-
-**Benefits:**
-- Better skill composition
-- Clearer skill relationships
-- Progressive disclosure
-
----
-
-## Conditional Enforcement
-
-**Current State:** Enforcement level is static
-
-**Future Enhancement:** Enforce based on context or environment
-
-**Configuration Idea:**
-```json
-{
- "enforcement": {
- "default": "suggest",
- "when": {
- "production": "block",
- "development": "suggest",
- "ci": "block"
- }
- }
-}
-```
-
-**Use Cases:**
-- Stricter enforcement in production
-- Relaxed rules during development
-- CI/CD pipeline requirements
-
-**Benefits:**
-- Environment-appropriate enforcement
-- Flexible rule application
-- Context-aware guardrails
-
----
-
-## Skill Analytics
-
-**Current State:** No usage tracking
-
-**Future Enhancement:** Track skill usage patterns and effectiveness
-
-**Metrics to Collect:**
-- Skill trigger frequency
-- False positive rate
-- False negative rate
-- Time to skill usage after suggestion
-- User override rate (skip markers, env vars)
-- Performance metrics (execution time)
-
-**Dashbord Ideas:**
-- Most/least used skills
-- Skills with highest false positive rate
-- Performance bottlenecks
-- Skill effectiveness scores
-
-**Benefits:**
-- Data-driven skill improvement
-- Identify problems early
-- Optimize patterns based on real usage
-
----
-
-## Skill Versioning
-
-**Current State:** No version tracking
-
-**Future Enhancement:** Version skills and track compatibility
-
-**Configuration Idea:**
-```json
-{
- "my-skill": {
- "version": "2.1.0",
- "minClaudeVersion": "1.5.0",
- "changelog": "Added support for new workflow patterns",
- ...
- }
-}
-```
-
-**Benefits:**
-- Track skill evolution
-- Ensure compatibility
-- Document changes
-- Support migration paths
-
----
-
-## Multi-Language Support
-
-**Current State:** English only
-
-**Future Enhancement:** Support multiple languages for skill content
-
-**Implementation Ideas:**
-- Language-specific SKILL.md variants
-- Automatic language detection
-- Fallback to English
-
-**Use Cases:**
-- International teams
-- Localized documentation
-- Multi-language projects
-
----
-
-## Skill Testing Framework
-
-**Current State:** Manual testing with npx tsx commands
-
-**Future Enhancement:** Automated skill testing
-
-**Features:**
-- Test cases for trigger patterns
-- Assertion framework
-- CI/CD integration
-- Coverage reports
-
-**Example Test:**
-```typescript
-describe('database-verification', () => {
- it('triggers on Prisma imports', () => {
- const result = testSkill({
- prompt: "add user tracking",
- file: "services/user.ts",
- content: "import { PrismaService } from './prisma'"
- });
-
- expect(result.triggered).toBe(true);
- expect(result.skill).toBe('database-verification');
- });
-});
-```
-
-**Benefits:**
-- Prevent regressions
-- Validate patterns before deployment
-- Confidence in changes
-
----
-
-## Related Files
-
-- [SKILL.md](SKILL.md) - Main skill guide
-- [TROUBLESHOOTING.md](TROUBLESHOOTING.md) - Current debugging guide
-- [HOOK_MECHANISMS.md](HOOK_MECHANISMS.md) - How hooks work today
diff --git a/.claude/skills/skill-developer/HOOK_MECHANISMS.md b/.claude/skills/skill-developer/HOOK_MECHANISMS.md
deleted file mode 100644
index abe4768c5b..0000000000
--- a/.claude/skills/skill-developer/HOOK_MECHANISMS.md
+++ /dev/null
@@ -1,306 +0,0 @@
-# Hook Mechanisms - Deep Dive
-
-Technical deep dive into how the UserPromptSubmit and PreToolUse hooks work.
-
-## Table of Contents
-
-- [UserPromptSubmit Hook Flow](#userpromptsubmit-hook-flow)
-- [PreToolUse Hook Flow](#pretooluse-hook-flow)
-- [Exit Code Behavior (CRITICAL)](#exit-code-behavior-critical)
-- [Session State Management](#session-state-management)
-- [Performance Considerations](#performance-considerations)
-
----
-
-## UserPromptSubmit Hook Flow
-
-### Execution Sequence
-
-```
-User submits prompt
- ↓
-.claude/settings.json registers hook
- ↓
-skill-activation-prompt.sh executes
- ↓
-npx tsx skill-activation-prompt.ts
- ↓
-Hook reads stdin (JSON with prompt)
- ↓
-Loads skill-rules.json
- ↓
-Matches keywords + intent patterns
- ↓
-Groups matches by priority (critical β†’ high β†’ medium β†’ low)
- ↓
-Outputs formatted message to stdout
- ↓
-stdout becomes context for Claude (injected before prompt)
- ↓
-Claude sees: [skill suggestion] + user's prompt
-```
-
-### Key Points
-
-- **Exit code**: Always 0 (allow)
-- **stdout**: β†’ Claude's context (injected as system message)
-- **Timing**: Runs BEFORE Claude processes prompt
-- **Behavior**: Non-blocking, advisory only
-- **Purpose**: Make Claude aware of relevant skills
-
-### Input Format
-
-```json
-{
- "session_id": "abc-123",
- "transcript_path": "/path/to/transcript.json",
- "cwd": "/root/git/your-project",
- "permission_mode": "normal",
- "hook_event_name": "UserPromptSubmit",
- "prompt": "how does the layout system work?"
-}
-```
-
-### Output Format (to stdout)
-
-```
-━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
-🎯 SKILL ACTIVATION CHECK
-━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
-
-πŸ“š RECOMMENDED SKILLS:
- β†’ project-catalog-developer
-
-ACTION: Use Skill tool BEFORE responding
-━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
-```
-
-Claude sees this output as additional context before processing the user's prompt.
-
----
-
-## PreToolUse Hook Flow
-
-### Execution Sequence
-
-```
-Claude calls Edit/Write tool
- ↓
-.claude/settings.json registers hook (matcher: Edit|Write)
- ↓
-skill-verification-guard.sh executes
- ↓
-npx tsx skill-verification-guard.ts
- ↓
-Hook reads stdin (JSON with tool_name, tool_input)
- ↓
-Loads skill-rules.json
- ↓
-Checks file path patterns (glob matching)
- ↓
-Reads file for content patterns (if file exists)
- ↓
-Checks session state (was skill already used?)
- ↓
-Checks skip conditions (file markers, env vars)
- ↓
-IF MATCHED AND NOT SKIPPED:
- Update session state (mark skill as enforced)
- Output block message to stderr
- Exit with code 2 (BLOCK)
-ELSE:
- Exit with code 0 (ALLOW)
- ↓
-IF BLOCKED:
- stderr β†’ Claude sees message
- Edit/Write tool does NOT execute
- Claude must use skill and retry
-IF ALLOWED:
- Tool executes normally
-```
-
-### Key Points
-
-- **Exit code 2**: BLOCK (stderr β†’ Claude)
-- **Exit code 0**: ALLOW
-- **Timing**: Runs BEFORE tool execution
-- **Session tracking**: Prevents repeated blocks in same session
-- **Fail open**: On errors, allows operation (don't break workflow)
-- **Purpose**: Enforce critical guardrails
-
-### Input Format
-
-```json
-{
- "session_id": "abc-123",
- "transcript_path": "/path/to/transcript.json",
- "cwd": "/root/git/your-project",
- "permission_mode": "normal",
- "hook_event_name": "PreToolUse",
- "tool_name": "Edit",
- "tool_input": {
- "file_path": "/root/git/your-project/form/src/services/user.ts",
- "old_string": "...",
- "new_string": "..."
- }
-}
-```
-
-### Output Format (to stderr when blocked)
-
-```
-⚠️ BLOCKED - Database Operation Detected
-
-πŸ“‹ REQUIRED ACTION:
-1. Use Skill tool: 'database-verification'
-2. Verify ALL table and column names against schema
-3. Check database structure with DESCRIBE commands
-4. Then retry this edit
-
-Reason: Prevent column name errors in Prisma queries
-File: form/src/services/user.ts
-
-πŸ’‘ TIP: Add '// @skip-validation' comment to skip future checks
-```
-
-Claude receives this message and understands it needs to use the skill before retrying the edit.
-
----
-
-## Exit Code Behavior (CRITICAL)
-
-### Exit Code Reference Table
-
-| Exit Code | stdout | stderr | Tool Execution | Claude Sees |
-|-----------|--------|--------|----------------|-------------|
-| 0 (UserPromptSubmit) | β†’ Context | β†’ User only | N/A | stdout content |
-| 0 (PreToolUse) | β†’ User only | β†’ User only | **Proceeds** | Nothing |
-| 2 (PreToolUse) | β†’ User only | β†’ **CLAUDE** | **BLOCKED** | stderr content |
-| Other | β†’ User only | β†’ User only | Blocked | Nothing |
-
-### Why Exit Code 2 Matters
-
-This is THE critical mechanism for enforcement:
-
-1. **Only way** to send message to Claude from PreToolUse
-2. stderr content is "fed back to Claude automatically"
-3. Claude sees the block message and understands what to do
-4. Tool execution is prevented
-5. Critical for enforcement of guardrails
-
-### Example Conversation Flow
-
-```
-User: "Add a new user service with Prisma"
-
-Claude: "I'll create the user service..."
- [Attempts to Edit form/src/services/user.ts]
-
-PreToolUse Hook: [Exit code 2]
- stderr: "⚠️ BLOCKED - Use database-verification"
-
-Claude sees error, responds:
- "I need to verify the database schema first."
- [Uses Skill tool: database-verification]
- [Verifies column names]
- [Retries Edit - now allowed (session tracking)]
-```
-
----
-
-## Session State Management
-
-### Purpose
-
-Prevent repeated nagging in the same session - once Claude uses a skill, don't block again.
-
-### State File Location
-
-`.claude/hooks/state/skills-used-{session_id}.json`
-
-### State File Structure
-
-```json
-{
- "skills_used": [
- "database-verification",
- "error-tracking"
- ],
- "files_verified": []
-}
-```
-
-### How It Works
-
-1. **First edit** of file with Prisma:
- - Hook blocks with exit code 2
- - Updates session state: adds "database-verification" to skills_used
- - Claude sees message, uses skill
-
-2. **Second edit** (same session):
- - Hook checks session state
- - Finds "database-verification" in skills_used
- - Exits with code 0 (allow)
- - No message to Claude
-
-3. **Different session**:
- - New session ID = new state file
- - Hook blocks again
-
-### Limitation
-
-The hook cannot detect when the skill is *actually* invoked - it just blocks once per session per skill. This means:
-
-- If Claude doesn't use the skill but makes a different edit, it won't block again
-- Trust that Claude follows the instruction
-- Future enhancement: detect actual Skill tool usage
-
----
-
-## Performance Considerations
-
-### Target Metrics
-
-- **UserPromptSubmit**: < 100ms
-- **PreToolUse**: < 200ms
-
-### Performance Bottlenecks
-
-1. **Loading skill-rules.json** (every execution)
- - Future: Cache in memory
- - Future: Watch for changes, reload only when needed
-
-2. **Reading file content** (PreToolUse)
- - Only when contentPatterns configured
- - Only if file exists
- - Can be slow for large files
-
-3. **Glob matching** (PreToolUse)
- - Regex compilation for each pattern
- - Future: Compile once, cache
-
-4. **Regex matching** (Both hooks)
- - Intent patterns (UserPromptSubmit)
- - Content patterns (PreToolUse)
- - Future: Lazy compile, cache compiled regexes
-
-### Optimization Strategies
-
-**Reduce patterns:**
-- Use more specific patterns (fewer to check)
-- Combine similar patterns where possible
-
-**File path patterns:**
-- More specific = fewer files to check
-- Example: `form/src/services/**` better than `form/**`
-
-**Content patterns:**
-- Only add when truly necessary
-- Simpler regex = faster matching
-
----
-
-**Related Files:**
-- [SKILL.md](SKILL.md) - Main skill guide
-- [TROUBLESHOOTING.md](TROUBLESHOOTING.md) - Debug hook issues
-- [SKILL_RULES_REFERENCE.md](SKILL_RULES_REFERENCE.md) - Configuration reference
diff --git a/.claude/skills/skill-developer/PATTERNS_LIBRARY.md b/.claude/skills/skill-developer/PATTERNS_LIBRARY.md
deleted file mode 100644
index 72209397f5..0000000000
--- a/.claude/skills/skill-developer/PATTERNS_LIBRARY.md
+++ /dev/null
@@ -1,152 +0,0 @@
-# Common Patterns Library
-
-Ready-to-use regex and glob patterns for skill triggers. Copy and customize for your skills.
-
----
-
-## Intent Patterns (Regex)
-
-### Feature/Endpoint Creation
-```regex
-(add|create|implement|build).*?(feature|endpoint|route|service|controller)
-```
-
-### Component Creation
-```regex
-(create|add|make|build).*?(component|UI|page|modal|dialog|form)
-```
-
-### Database Work
-```regex
-(add|create|modify|update).*?(user|table|column|field|schema|migration)
-(database|prisma).*?(change|update|query)
-```
-
-### Error Handling
-```regex
-(fix|handle|catch|debug).*?(error|exception|bug)
-(add|implement).*?(try|catch|error.*?handling)
-```
-
-### Explanation Requests
-```regex
-(how does|how do|explain|what is|describe|tell me about).*?
-```
-
-### Workflow Operations
-```regex
-(create|add|modify|update).*?(workflow|step|branch|condition)
-(debug|troubleshoot|fix).*?workflow
-```
-
-### Testing
-```regex
-(write|create|add).*?(test|spec|unit.*?test)
-```
-
----
-
-## File Path Patterns (Glob)
-
-### Frontend
-```glob
-frontend/src/**/*.tsx # All React components
-frontend/src/**/*.ts # All TypeScript files
-frontend/src/components/** # Only components directory
-```
-
-### Backend Services
-```glob
-form/src/**/*.ts # Form service
-email/src/**/*.ts # Email service
-users/src/**/*.ts # Users service
-projects/src/**/*.ts # Projects service
-```
-
-### Database
-```glob
-**/schema.prisma # Prisma schema (anywhere)
-**/migrations/**/*.sql # Migration files
-database/src/**/*.ts # Database scripts
-```
-
-### Workflows
-```glob
-form/src/workflow/**/*.ts # Workflow engine
-form/src/workflow-definitions/**/*.json # Workflow definitions
-```
-
-### Test Exclusions
-```glob
-**/*.test.ts # TypeScript tests
-**/*.test.tsx # React component tests
-**/*.spec.ts # Spec files
-```
-
----
-
-## Content Patterns (Regex)
-
-### Prisma/Database
-```regex
-import.*[Pp]risma # Prisma imports
-PrismaService # PrismaService usage
-prisma\. # prisma.something
-\.findMany\( # Prisma query methods
-\.create\(
-\.update\(
-\.delete\(
-```
-
-### Controllers/Routes
-```regex
-export class.*Controller # Controller classes
-router\. # Express router
-app\.(get|post|put|delete|patch) # Express app routes
-```
-
-### Error Handling
-```regex
-try\s*\{ # Try blocks
-catch\s*\( # Catch blocks
-throw new # Throw statements
-```
-
-### React/Components
-```regex
-export.*React\.FC # React functional components
-export default function.* # Default function exports
-useState|useEffect # React hooks
-```
-
----
-
-**Usage Example:**
-
-```json
-{
- "my-skill": {
- "promptTriggers": {
- "intentPatterns": [
- "(create|add|build).*?(component|UI|page)"
- ]
- },
- "fileTriggers": {
- "pathPatterns": [
- "frontend/src/**/*.tsx"
- ],
- "contentPatterns": [
- "export.*React\\.FC",
- "useState|useEffect"
- ]
- }
- }
-}
-```
-
----
-
-**Related Files:**
-- [SKILL.md](SKILL.md) - Main skill guide
-- [TRIGGER_TYPES.md](TRIGGER_TYPES.md) - Detailed trigger documentation
-- [SKILL_RULES_REFERENCE.md](SKILL_RULES_REFERENCE.md) - Complete schema
diff --git a/.claude/skills/skill-developer/SKILL.md b/.claude/skills/skill-developer/SKILL.md
deleted file mode 100644
index 4c26d2dd40..0000000000
--- a/.claude/skills/skill-developer/SKILL.md
+++ /dev/null
@@ -1,426 +0,0 @@
----
-name: skill-developer
-description: Create and manage Claude Code skills following Anthropic best practices. Use when creating new skills, modifying skill-rules.json, understanding trigger patterns, working with hooks, debugging skill activation, or implementing progressive disclosure. Covers skill structure, YAML frontmatter, trigger types (keywords, intent patterns, file paths, content patterns), enforcement levels (block, suggest, warn), hook mechanisms (UserPromptSubmit, PreToolUse), session tracking, and the 500-line rule.
----
-
-# Skill Developer Guide
-
-## Purpose
-
-Comprehensive guide for creating and managing skills in Claude Code with auto-activation system, following Anthropic's official best practices including the 500-line rule and progressive disclosure pattern.
-
-## When to Use This Skill
-
-Automatically activates when you mention:
-- Creating or adding skills
-- Modifying skill triggers or rules
-- Understanding how skill activation works
-- Debugging skill activation issues
-- Working with skill-rules.json
-- Hook system mechanics
-- Claude Code best practices
-- Progressive disclosure
-- YAML frontmatter
-- 500-line rule
-
----
-
-## System Overview
-
-### Two-Hook Architecture
-
-**1. UserPromptSubmit Hook** (Proactive Suggestions)
-- **File**: `.claude/hooks/skill-activation-prompt.ts`
-- **Trigger**: BEFORE Claude sees user's prompt
-- **Purpose**: Suggest relevant skills based on keywords + intent patterns
-- **Method**: Injects formatted reminder as context (stdout β†’ Claude's input)
-- **Use Cases**: Topic-based skills, implicit work detection
-
-**2. Stop Hook - Error Handling Reminder** (Gentle Reminders)
-- **File**: `.claude/hooks/error-handling-reminder.ts`
-- **Trigger**: AFTER Claude finishes responding
-- **Purpose**: Gentle reminder to self-assess error handling in code written
-- **Method**: Analyzes edited files for risky patterns, displays reminder if needed
-- **Use Cases**: Error handling awareness without blocking friction
-
-**Philosophy Change (2025-10-27):** We moved away from blocking PreToolUse for Sentry/error handling. Instead, use gentle post-response reminders that don't block workflow but maintain code quality awareness.
-
-### Configuration File
-
-**Location**: `.claude/skills/skill-rules.json`
-
-Defines:
-- All skills and their trigger conditions
-- Enforcement levels (block, suggest, warn)
-- File path patterns (glob)
-- Content detection patterns (regex)
-- Skip conditions (session tracking, file markers, env vars)
-
----
-
-## Skill Types
-
-### 1. Guardrail Skills
-
-**Purpose:** Enforce critical best practices that prevent errors
-
-**Characteristics:**
-- Type: `"guardrail"`
-- Enforcement: `"block"`
-- Priority: `"critical"` or `"high"`
-- Block file edits until skill used
-- Prevent common mistakes (column names, critical errors)
-- Session-aware (don't repeat nag in same session)
-
-**Examples:**
-- `database-verification` - Verify table/column names before Prisma queries
-- `frontend-dev-guidelines` - Enforce React/TypeScript patterns
-
-**When to Use:**
-- Mistakes that cause runtime errors
-- Data integrity concerns
-- Critical compatibility issues
-
-### 2. Domain Skills
-
-**Purpose:** Provide comprehensive guidance for specific areas
-
-**Characteristics:**
-- Type: `"domain"`
-- Enforcement: `"suggest"`
-- Priority: `"high"` or `"medium"`
-- Advisory, not mandatory
-- Topic or domain-specific
-- Comprehensive documentation
-
-**Examples:**
-- `backend-dev-guidelines` - Node.js/Express/TypeScript patterns
-- `frontend-dev-guidelines` - React/TypeScript best practices
-- `error-tracking` - Sentry integration guidance
-
-**When to Use:**
-- Complex systems requiring deep knowledge
-- Best practices documentation
-- Architectural patterns
-- How-to guides
-
----
-
-## Quick Start: Creating a New Skill
-
-### Step 1: Create Skill File
-
-**Location:** `.claude/skills/{skill-name}/SKILL.md`
-
-**Template:**
-```markdown
----
-name: my-new-skill
-description: Brief description including keywords that trigger this skill. Mention topics, file types, and use cases. Be explicit about trigger terms.
----
-
-# My New Skill
-
-## Purpose
-What this skill helps with
-
-## When to Use
-Specific scenarios and conditions
-
-## Key Information
-The actual guidance, documentation, patterns, examples
-```
-
-**Best Practices:**
-- βœ… **Name**: Lowercase, hyphens, gerund form (verb + -ing) preferred
-- βœ… **Description**: Include ALL trigger keywords/phrases (max 1024 chars)
-- βœ… **Content**: Under 500 lines - use reference files for details
-- βœ… **Examples**: Real code examples
-- βœ… **Structure**: Clear headings, lists, code blocks
-
-### Step 2: Add to skill-rules.json
-
-See [SKILL_RULES_REFERENCE.md](SKILL_RULES_REFERENCE.md) for complete schema.
-
-**Basic Template:**
-```json
-{
- "my-new-skill": {
- "type": "domain",
- "enforcement": "suggest",
- "priority": "medium",
- "promptTriggers": {
- "keywords": ["keyword1", "keyword2"],
- "intentPatterns": ["(create|add).*?something"]
- }
- }
-}
-```
-
-### Step 3: Test Triggers
-
-**Test UserPromptSubmit:**
-```bash
-echo '{"session_id":"test","prompt":"your test prompt"}' | \
- npx tsx .claude/hooks/skill-activation-prompt.ts
-```
-
-**Test PreToolUse:**
-```bash
-cat <<'EOF' | npx tsx .claude/hooks/skill-verification-guard.ts
-{"session_id":"test","tool_name":"Edit","tool_input":{"file_path":"test.ts"}}
-EOF
-```
-
-### Step 4: Refine Patterns
-
-Based on testing:
-- Add missing keywords
-- Refine intent patterns to reduce false positives
-- Adjust file path patterns
-- Test content patterns against actual files
-
-### Step 5: Follow Anthropic Best Practices
-
-βœ… Keep SKILL.md under 500 lines
-βœ… Use progressive disclosure with reference files
-βœ… Add table of contents to reference files > 100 lines
-βœ… Write detailed description with trigger keywords
-βœ… Test with 3+ real scenarios before documenting
-βœ… Iterate based on actual usage
-
----
-
-## Enforcement Levels
-
-### BLOCK (Critical Guardrails)
-
-- Physically prevents Edit/Write tool execution
-- Exit code 2 from hook, stderr β†’ Claude
-- Claude sees message and must use skill to proceed
-- **Use For**: Critical mistakes, data integrity, security issues
-
-**Example:** Database column name verification
-
-### SUGGEST (Recommended)
-
-- Reminder injected before Claude sees prompt
-- Claude is aware of relevant skills
-- Not enforced, just advisory
-- **Use For**: Domain guidance, best practices, how-to guides
-
-**Example:** Frontend development guidelines
-
-### WARN (Optional)
-
-- Low priority suggestions
-- Advisory only, minimal enforcement
-- **Use For**: Nice-to-have suggestions, informational reminders
-
-**Rarely used** - most skills are either BLOCK or SUGGEST.
-
----
-
-## Skip Conditions & User Control
-
-### 1. Session Tracking
-
-**Purpose:** Don't nag repeatedly in same session
-
-**How it works:**
-- First edit β†’ Hook blocks, updates session state
-- Second edit (same session) β†’ Hook allows
-- Different session β†’ Blocks again
-
-**State File:** `.claude/hooks/state/skills-used-{session_id}.json`
-
-### 2. File Markers
-
-**Purpose:** Permanent skip for verified files
-
-**Marker:** `// @skip-validation`
-
-**Usage:**
-```typescript
-// @skip-validation
-import { PrismaService } from './prisma';
-// This file has been manually verified
-```
-
-**NOTE:** Use sparingly - defeats the purpose if overused
-
-### 3. Environment Variables
-
-**Purpose:** Emergency disable, temporary override
-
-**Global disable:**
-```bash
-export SKIP_SKILL_GUARDRAILS=true # Disables ALL PreToolUse blocks
-```
-
-**Skill-specific:**
-```bash
-export SKIP_DB_VERIFICATION=true
-export SKIP_ERROR_REMINDER=true
-```
-
----
-
-## Testing Checklist
-
-When creating a new skill, verify:
-
-- [ ] Skill file created in `.claude/skills/{name}/SKILL.md`
-- [ ] Proper frontmatter with name and description
-- [ ] Entry added to `skill-rules.json`
-- [ ] Keywords tested with real prompts
-- [ ] Intent patterns tested with variations
-- [ ] File path patterns tested with actual files
-- [ ] Content patterns tested against file contents
-- [ ] Block message is clear and actionable (if guardrail)
-- [ ] Skip conditions configured appropriately
-- [ ] Priority level matches importance
-- [ ] No false positives in testing
-- [ ] No false negatives in testing
-- [ ] Performance is acceptable (<100ms or <200ms)
-- [ ] JSON syntax validated: `jq . skill-rules.json`
-- [ ] **SKILL.md under 500 lines** ⭐
-- [ ] Reference files created if needed
-- [ ] Table of contents added to files > 100 lines
-
----
-
-## Reference Files
-
-For detailed information on specific topics, see:
-
-### [TRIGGER_TYPES.md](TRIGGER_TYPES.md)
-Complete guide to all trigger types:
-- Keyword triggers (explicit topic matching)
-- Intent patterns (implicit action detection)
-- File path triggers (glob patterns)
-- Content patterns (regex in files)
-- Best practices and examples for each
-- Common pitfalls and testing strategies
-
-### [SKILL_RULES_REFERENCE.md](SKILL_RULES_REFERENCE.md)
-Complete skill-rules.json schema:
-- Full TypeScript interface definitions
-- Field-by-field explanations
-- Complete guardrail skill example
-- Complete domain skill example
-- Validation guide and common errors
-
-### [HOOK_MECHANISMS.md](HOOK_MECHANISMS.md)
-Deep dive into hook internals:
-- UserPromptSubmit flow (detailed)
-- PreToolUse flow (detailed)
-- Exit code behavior table (CRITICAL)
-- Session state management
-- Performance considerations
-
-### [TROUBLESHOOTING.md](TROUBLESHOOTING.md)
-Comprehensive debugging guide:
-- Skill not triggering (UserPromptSubmit)
-- PreToolUse not blocking
-- False positives (too many triggers)
-- Hook not executing at all
-- Performance issues
-
-### [PATTERNS_LIBRARY.md](PATTERNS_LIBRARY.md)
-Ready-to-use pattern collection:
-- Intent pattern library (regex)
-- File path pattern library (glob)
-- Content pattern library (regex)
-- Organized by use case
-- Copy-paste ready
-
-### [ADVANCED.md](ADVANCED.md)
-Future enhancements and ideas:
-- Dynamic rule updates
-- Skill dependencies
-- Conditional enforcement
-- Skill analytics
-- Skill versioning
-
----
-
-## Quick Reference Summary
-
-### Create New Skill (5 Steps)
-
-1. Create `.claude/skills/{name}/SKILL.md` with frontmatter
-2. Add entry to `.claude/skills/skill-rules.json`
-3. Test with `npx tsx` commands
-4. Refine patterns based on testing
-5. Keep SKILL.md under 500 lines
-
-### Trigger Types
-
-- **Keywords**: Explicit topic mentions
-- **Intent**: Implicit action detection
-- **File Paths**: Location-based activation
-- **Content**: Technology-specific detection
-
-See [TRIGGER_TYPES.md](TRIGGER_TYPES.md) for complete details.
-
-### Enforcement
-
-- **BLOCK**: Exit code 2, critical only
-- **SUGGEST**: Inject context, most common
-- **WARN**: Advisory, rarely used
-
-### Skip Conditions
-
-- **Session tracking**: Automatic (prevents repeated nags)
-- **File markers**: `// @skip-validation` (permanent skip)
-- **Env vars**: `SKIP_SKILL_GUARDRAILS` (emergency disable)
-
-### Anthropic Best Practices
-
-βœ… **500-line rule**: Keep SKILL.md under 500 lines
-βœ… **Progressive disclosure**: Use reference files for details
-βœ… **Table of contents**: Add to reference files > 100 lines
-βœ… **One level deep**: Don't nest references deeply
-βœ… **Rich descriptions**: Include all trigger keywords (max 1024 chars)
-βœ… **Test first**: Build 3+ evaluations before extensive documentation
-βœ… **Gerund naming**: Prefer verb + -ing (e.g., "processing-pdfs")
-
-### Troubleshoot
-
-Test hooks manually:
-```bash
-# UserPromptSubmit
-echo '{"prompt":"test"}' | npx tsx .claude/hooks/skill-activation-prompt.ts
-
-# PreToolUse
-cat <<'EOF' | npx tsx .claude/hooks/skill-verification-guard.ts
-{"tool_name":"Edit","tool_input":{"file_path":"test.ts"}}
-EOF
-```
-
-See [TROUBLESHOOTING.md](TROUBLESHOOTING.md) for complete debugging guide.
-
----
-
-## Related Files
-
-**Configuration:**
-- `.claude/skills/skill-rules.json` - Master configuration
-- `.claude/hooks/state/` - Session tracking
-- `.claude/settings.json` - Hook registration
-
-**Hooks:**
-- `.claude/hooks/skill-activation-prompt.ts` - UserPromptSubmit
-- `.claude/hooks/error-handling-reminder.ts` - Stop event (gentle reminders)
-
-**All Skills:**
-- `.claude/skills/*/SKILL.md` - Skill content files
-
----
-
-**Skill Status**: COMPLETE - Restructured following Anthropic best practices βœ…
-**Line Count**: < 500 (following 500-line rule) βœ…
-**Progressive Disclosure**: Reference files for detailed information βœ…
-
-**Next**: Create more skills, refine patterns based on usage
diff --git a/.claude/skills/skill-developer/SKILL_RULES_REFERENCE.md b/.claude/skills/skill-developer/SKILL_RULES_REFERENCE.md
deleted file mode 100644
index 1cad7d9b38..0000000000
--- a/.claude/skills/skill-developer/SKILL_RULES_REFERENCE.md
+++ /dev/null
@@ -1,315 +0,0 @@
-# skill-rules.json - Complete Reference
-
-Complete schema and configuration reference for `.claude/skills/skill-rules.json`.
-
-## Table of Contents
-
-- [File Location](#file-location)
-- [Complete TypeScript Schema](#complete-typescript-schema)
-- [Field Guide](#field-guide)
-- [Example: Guardrail Skill](#example-guardrail-skill)
-- [Example: Domain Skill](#example-domain-skill)
-- [Validation](#validation)
-
----
-
-## File Location
-
-**Path:** `.claude/skills/skill-rules.json`
-
-This JSON file defines all skills and their trigger conditions for the auto-activation system.
-
----
-
-## Complete TypeScript Schema
-
-```typescript
-interface SkillRules {
- version: string;
- skills: Record<string, SkillRule>;
-}
-
-interface SkillRule {
- type: 'guardrail' | 'domain';
- enforcement: 'block' | 'suggest' | 'warn';
- priority: 'critical' | 'high' | 'medium' | 'low';
-
- promptTriggers?: {
- keywords?: string[];
- intentPatterns?: string[]; // Regex strings
- };
-
- fileTriggers?: {
- pathPatterns: string[]; // Glob patterns
- pathExclusions?: string[]; // Glob patterns
- contentPatterns?: string[]; // Regex strings
- createOnly?: boolean; // Only trigger on file creation
- };
-
- blockMessage?: string; // For guardrails, {file_path} placeholder
-
- skipConditions?: {
- sessionSkillUsed?: boolean; // Skip if used in session
- fileMarkers?: string[]; // e.g., ["@skip-validation"]
- envOverride?: string; // e.g., "SKIP_DB_VERIFICATION"
- };
-}
-```
-
----
-
-## Field Guide
-
-### Top Level
-
-| Field | Type | Required | Description |
-|-------|------|----------|-------------|
-| `version` | string | Yes | Schema version (currently "1.0") |
-| `skills` | object | Yes | Map of skill name β†’ SkillRule |
-
-### SkillRule Fields
-
-| Field | Type | Required | Description |
-|-------|------|----------|-------------|
-| `type` | string | Yes | "guardrail" (enforced) or "domain" (advisory) |
-| `enforcement` | string | Yes | "block" (PreToolUse), "suggest" (UserPromptSubmit), or "warn" |
-| `priority` | string | Yes | "critical", "high", "medium", or "low" |
-| `promptTriggers` | object | Optional | Triggers for UserPromptSubmit hook |
-| `fileTriggers` | object | Optional | Triggers for PreToolUse hook |
-| `blockMessage` | string | Optional* | Required if enforcement="block". Use `{file_path}` placeholder |
-| `skipConditions` | object | Optional | Escape hatches and session tracking |
-
-*Required for guardrails
-
-### promptTriggers Fields
-
-| Field | Type | Required | Description |
-|-------|------|----------|-------------|
-| `keywords` | string[] | Optional | Exact substring matches (case-insensitive) |
-| `intentPatterns` | string[] | Optional | Regex patterns for intent detection |
-
-### fileTriggers Fields
-
-| Field | Type | Required | Description |
-|-------|------|----------|-------------|
-| `pathPatterns` | string[] | Yes* | Glob patterns for file paths |
-| `pathExclusions` | string[] | Optional | Glob patterns to exclude (e.g., test files) |
-| `contentPatterns` | string[] | Optional | Regex patterns to match file content |
-| `createOnly` | boolean | Optional | Only trigger when creating new files |
-
-*Required if fileTriggers is present
-
-### skipConditions Fields
-
-| Field | Type | Required | Description |
-|-------|------|----------|-------------|
-| `sessionSkillUsed` | boolean | Optional | Skip if skill already used this session |
-| `fileMarkers` | string[] | Optional | Skip if file contains comment marker |
-| `envOverride` | string | Optional | Environment variable name to disable skill |
-
----
-
-## Example: Guardrail Skill
-
-Complete example of a blocking guardrail skill with all features:
-
-```json
-{
- "database-verification": {
- "type": "guardrail",
- "enforcement": "block",
- "priority": "critical",
-
- "promptTriggers": {
- "keywords": [
- "prisma",
- "database",
- "table",
- "column",
- "schema",
- "query",
- "migration"
- ],
- "intentPatterns": [
- "(add|create|implement).*?(user|login|auth|tracking|feature)",
- "(modify|update|change).*?(table|column|schema|field)",
- "database.*?(change|update|modify|migration)"
- ]
- },
-
- "fileTriggers": {
- "pathPatterns": [
- "**/schema.prisma",
- "**/migrations/**/*.sql",
- "database/src/**/*.ts",
- "form/src/**/*.ts",
- "email/src/**/*.ts",
- "users/src/**/*.ts",
- "projects/src/**/*.ts",
- "utilities/src/**/*.ts"
- ],
- "pathExclusions": [
- "**/*.test.ts",
- "**/*.spec.ts"
- ],
- "contentPatterns": [
- "import.*[Pp]risma",
- "PrismaService",
- "prisma\\.",
- "\\.findMany\\(",
- "\\.findUnique\\(",
- "\\.findFirst\\(",
- "\\.create\\(",
- "\\.createMany\\(",
- "\\.update\\(",
- "\\.updateMany\\(",
- "\\.upsert\\(",
- "\\.delete\\(",
- "\\.deleteMany\\("
- ]
- },
-
- "blockMessage": "⚠️ BLOCKED - Database Operation Detected\n\nπŸ“‹ REQUIRED ACTION:\n1. Use Skill tool: 'database-verification'\n2. Verify ALL table and column names against schema\n3. Check database structure with DESCRIBE commands\n4. Then retry this edit\n\nReason: Prevent column name errors in Prisma queries\nFile: {file_path}\n\nπŸ’‘ TIP: Add '// @skip-validation' comment to skip future checks",
-
- "skipConditions": {
- "sessionSkillUsed": true,
- "fileMarkers": [
- "@skip-validation"
- ],
- "envOverride": "SKIP_DB_VERIFICATION"
- }
- }
-}
-```
-
-### Key Points for Guardrails
-
-1. **type**: Must be "guardrail"
-2. **enforcement**: Must be "block"
-3. **priority**: Usually "critical" or "high"
-4. **blockMessage**: Required, clear actionable steps
-5. **skipConditions**: Session tracking prevents repeated nagging
-6. **fileTriggers**: Usually has both path and content patterns
-7. **contentPatterns**: Catch actual usage of technology
-
----
-
-## Example: Domain Skill
-
-Complete example of a suggestion-based domain skill:
-
-```json
-{
- "project-catalog-developer": {
- "type": "domain",
- "enforcement": "suggest",
- "priority": "high",
-
- "promptTriggers": {
- "keywords": [
- "layout",
- "layout system",
- "grid",
- "grid layout",
- "toolbar",
- "column",
- "cell editor",
- "cell renderer",
- "submission",
- "submissions",
- "blog dashboard",
- "datagrid",
- "data grid",
- "CustomToolbar",
- "GridLayoutDialog",
- "useGridLayout",
- "auto-save",
- "column order",
- "column width",
- "filter",
- "sort"
- ],
- "intentPatterns": [
- "(how does|how do|explain|what is|describe).*?(layout|grid|toolbar|column|submission|catalog)",
- "(add|create|modify|change).*?(toolbar|column|cell|editor|renderer)",
- "blog dashboard.*?"
- ]
- },
-
- "fileTriggers": {
- "pathPatterns": [
- "frontend/src/features/submissions/**/*.tsx",
- "frontend/src/features/submissions/**/*.ts"
- ],
- "pathExclusions": [
- "**/*.test.tsx",
- "**/*.test.ts"
- ]
- }
- }
-}
-```
-
-### Key Points for Domain Skills
-
-1. **type**: Must be "domain"
-2. **enforcement**: Usually "suggest"
-3. **priority**: "high" or "medium"
-4. **blockMessage**: Not needed (doesn't block)
-5. **skipConditions**: Optional (less critical)
-6. **promptTriggers**: Usually has extensive keywords
-7. **fileTriggers**: May have only path patterns (content less important)
-
----
-
-## Validation
-
-### Check JSON Syntax
-
-```bash
-cat .claude/skills/skill-rules.json | jq .
-```
-
-If valid, jq will pretty-print the JSON. If invalid, it will show the error.
-
-### Common JSON Errors
-
-**Trailing comma:**
-```json
-{
- "keywords": ["one", "two",] // ❌ Trailing comma
-}
-```
-
-**Missing quotes:**
-```json
-{
- type: "guardrail" // ❌ Missing quotes on key
-}
-```
-
-**Single quotes (invalid JSON):**
-```json
-{
- 'type': 'guardrail' // ❌ Must use double quotes
-}
-```
-
-### Validation Checklist
-
-- [ ] JSON syntax valid (use `jq`)
-- [ ] All skill names match SKILL.md filenames
-- [ ] Guardrails have `blockMessage`
-- [ ] Block messages use `{file_path}` placeholder
-- [ ] Intent patterns are valid regex (test on regex101.com)
-- [ ] File path patterns use correct glob syntax
-- [ ] Content patterns escape special characters
-- [ ] Priority matches enforcement level
-- [ ] No duplicate skill names
-
----
-
-**Related Files:**
-- [SKILL.md](SKILL.md) - Main skill guide
-- [TRIGGER_TYPES.md](TRIGGER_TYPES.md) - Complete trigger documentation
-- [TROUBLESHOOTING.md](TROUBLESHOOTING.md) - Debugging configuration issues
diff --git a/.claude/skills/skill-developer/TRIGGER_TYPES.md b/.claude/skills/skill-developer/TRIGGER_TYPES.md
deleted file mode 100644
index dd61951cf3..0000000000
--- a/.claude/skills/skill-developer/TRIGGER_TYPES.md
+++ /dev/null
@@ -1,305 +0,0 @@
-# Trigger Types - Complete Guide
-
-Complete reference for configuring skill triggers in Claude Code's skill auto-activation system.
-
-## Table of Contents
-
-- [Keyword Triggers (Explicit)](#keyword-triggers-explicit)
-- [Intent Pattern Triggers (Implicit)](#intent-pattern-triggers-implicit)
-- [File Path Triggers](#file-path-triggers)
-- [Content Pattern Triggers](#content-pattern-triggers)
-- [Best Practices Summary](#best-practices-summary)
-
----
-
-## Keyword Triggers (Explicit)
-
-### How It Works
-
-Case-insensitive substring matching in user's prompt.
-
-### Use For
-
-Topic-based activation where user explicitly mentions the subject.
-
-### Configuration
-
-```json
-"promptTriggers": {
- "keywords": ["layout", "grid", "toolbar", "submission"]
-}
-```
-
-### Example
-
-- User prompt: "how does the **layout** system work?"
-- Matches: "layout" keyword
-- Activates: `project-catalog-developer`
-
-### Best Practices
-
-- Use specific, unambiguous terms
-- Include common variations ("layout", "layout system", "grid layout")
-- Avoid overly generic words ("system", "work", "create")
-- Test with real prompts
-
----
-
-## Intent Pattern Triggers (Implicit)
-
-### How It Works
-
-Regex pattern matching to detect user's intent even when they don't mention the topic explicitly.
-
-### Use For
-
-Action-based activation where user describes what they want to do rather than the specific topic.
-
-### Configuration
-
-```json
-"promptTriggers": {
- "intentPatterns": [
- "(create|add|implement).*?(feature|endpoint)",
- "(how does|explain).*?(layout|workflow)"
- ]
-}
-```
-
-### Examples
-
-**Database Work:**
-- User prompt: "add user tracking feature"
-- Matches: `(add).*?(feature)`
-- Activates: `database-verification`, `error-tracking`
-
-**Component Creation:**
-- User prompt: "create a dashboard widget"
-- Matches: `(create).*?(component)` (if component in pattern)
-- Activates: `frontend-dev-guidelines`
-
-### Best Practices
-
-- Capture common action verbs: `(create|add|modify|build|implement)`
-- Include domain-specific nouns: `(feature|endpoint|component|workflow)`
-- Use non-greedy matching: `.*?` instead of `.*`
-- Test patterns thoroughly with regex tester (https://regex101.com/)
-- Don't make patterns too broad (causes false positives)
-- Don't make patterns too specific (causes false negatives)
-
-### Common Pattern Examples
-
-```regex
-# Database Work
-(add|create|implement).*?(user|login|auth|feature)
-
-# Explanations
-(how does|explain|what is|describe).*?
-
-# Frontend Work
-(create|add|make|build).*?(component|UI|page|modal|dialog)
-
-# Error Handling
-(fix|handle|catch|debug).*?(error|exception|bug)
-
-# Workflow Operations
-(create|add|modify).*?(workflow|step|branch|condition)
-```
-
----
-
-## File Path Triggers
-
-### How It Works
-
-Glob pattern matching against the file path being edited.
-
-### Use For
-
-Domain/area-specific activation based on file location in the project.
-
-### Configuration
-
-```json
-"fileTriggers": {
- "pathPatterns": [
- "frontend/src/**/*.tsx",
- "form/src/**/*.ts"
- ],
- "pathExclusions": [
- "**/*.test.ts",
- "**/*.spec.ts"
- ]
-}
-```
-
-### Glob Pattern Syntax
-
-- `**` = Any number of directories (including zero)
-- `*` = Any characters within a directory name
-- Examples:
- - `frontend/src/**/*.tsx` = All .tsx files in frontend/src and subdirs
- - `**/schema.prisma` = schema.prisma anywhere in project
- - `form/src/**/*.ts` = All .ts files in form/src subdirs
-
-### Example
-
-- File being edited: `frontend/src/components/Dashboard.tsx`
-- Matches: `frontend/src/**/*.tsx`
-- Activates: `frontend-dev-guidelines`
-
-### Best Practices
-
-- Be specific to avoid false positives
-- Use exclusions for test files: `**/*.test.ts`
-- Consider subdirectory structure
-- Test patterns with actual file paths
-- Use narrower patterns when possible: `form/src/services/**` not `form/**`
-
-### Common Path Patterns
-
-```glob
-# Frontend
-frontend/src/**/*.tsx # All React components
-frontend/src/**/*.ts # All TypeScript files
-frontend/src/components/** # Only components directory
-
-# Backend Services
-form/src/**/*.ts # Form service
-email/src/**/*.ts # Email service
-users/src/**/*.ts # Users service
-
-# Database
-**/schema.prisma # Prisma schema (anywhere)
-**/migrations/**/*.sql # Migration files
-database/src/**/*.ts # Database scripts
-
-# Workflows
-form/src/workflow/**/*.ts # Workflow engine
-form/src/workflow-definitions/**/*.json # Workflow definitions
-
-# Test Exclusions
-**/*.test.ts # TypeScript tests
-**/*.test.tsx # React component tests
-**/*.spec.ts # Spec files
-```
-
----
-
-## Content Pattern Triggers
-
-### How It Works
-
-Regex pattern matching against the file's actual content (what's inside the file).
-
-### Use For
-
-Technology-specific activation based on what the code imports or uses (Prisma, controllers, specific libraries).
-
-### Configuration
-
-```json
-"fileTriggers": {
- "contentPatterns": [
- "import.*[Pp]risma",
- "PrismaService",
- "\\.findMany\\(",
- "\\.create\\("
- ]
-}
-```
-
-### Examples
-
-**Prisma Detection:**
-- File contains: `import { PrismaService } from '@project/database'`
-- Matches: `import.*[Pp]risma`
-- Activates: `database-verification`
-
-**Controller Detection:**
-- File contains: `export class UserController {`
-- Matches: `export class.*Controller`
-- Activates: `error-tracking`
-
-### Best Practices
-
-- Match imports: `import.*[Pp]risma` (case-insensitive with [Pp])
-- Escape special regex chars: `\\.findMany\\(` not `.findMany(`
-- Patterns use case-insensitive flag
-- Test against real file content
-- Make patterns specific enough to avoid false matches
-
-### Common Content Patterns
-
-```regex
-# Prisma/Database
-import.*[Pp]risma # Prisma imports
-PrismaService # PrismaService usage
-prisma\. # prisma.something
-\.findMany\( # Prisma query methods
-\.create\(
-\.update\(
-\.delete\(
-
-# Controllers/Routes
-export class.*Controller # Controller classes
-router\. # Express router
-app\.(get|post|put|delete|patch) # Express app routes
-
-# Error Handling
-try\s*\{ # Try blocks
-catch\s*\( # Catch blocks
-throw new # Throw statements
-
-# React/Components
-export.*React\.FC # React functional components
-export default function.* # Default function exports
-useState|useEffect # React hooks
-```
-
----
-
-## Best Practices Summary
-
-### DO:
-βœ… Use specific, unambiguous keywords
-βœ… Test all patterns with real examples
-βœ… Include common variations
-βœ… Use non-greedy regex: `.*?`
-βœ… Escape special characters in content patterns
-βœ… Add exclusions for test files
-βœ… Make file path patterns narrow and specific
-
-### DON'T:
-❌ Use overly generic keywords ("system", "work")
-❌ Make intent patterns too broad (false positives)
-❌ Make patterns too specific (false negatives)
-❌ Forget to test with regex tester (https://regex101.com/)
-❌ Use greedy regex: `.*` instead of `.*?`
-❌ Match too broadly in file paths
-
-### Testing Your Triggers
-
-**Test keyword/intent triggers:**
-```bash
-echo '{"session_id":"test","prompt":"your test prompt"}' | \
- npx tsx .claude/hooks/skill-activation-prompt.ts
-```
-
-**Test file path/content triggers:**
-```bash
-cat <<'EOF' | npx tsx .claude/hooks/skill-verification-guard.ts
-{
- "session_id": "test",
- "tool_name": "Edit",
- "tool_input": {"file_path": "/path/to/test/file.ts"}
-}
-EOF
-```
-
----
-
-**Related Files:**
-- [SKILL.md](SKILL.md) - Main skill guide
-- [SKILL_RULES_REFERENCE.md](SKILL_RULES_REFERENCE.md) - Complete skill-rules.json schema
-- [PATTERNS_LIBRARY.md](PATTERNS_LIBRARY.md) - Ready-to-use pattern library
diff --git a/.claude/skills/skill-developer/TROUBLESHOOTING.md b/.claude/skills/skill-developer/TROUBLESHOOTING.md
deleted file mode 100644
index f8cd3d38f6..0000000000
--- a/.claude/skills/skill-developer/TROUBLESHOOTING.md
+++ /dev/null
@@ -1,514 +0,0 @@
-# Troubleshooting - Skill Activation Issues
-
-Complete debugging guide for skill activation problems.
-
-## Table of Contents
-
-- [Skill Not Triggering](#skill-not-triggering)
- - [UserPromptSubmit Not Suggesting](#userpromptsubmit-not-suggesting)
- - [PreToolUse Not Blocking](#pretooluse-not-blocking)
-- [False Positives](#false-positives)
-- [Hook Not Executing](#hook-not-executing)
-- [Performance Issues](#performance-issues)
-
----
-
-## Skill Not Triggering
-
-### UserPromptSubmit Not Suggesting
-
-**Symptoms:** Ask a question, but no skill suggestion appears in output.
-
-**Common Causes:**
-
-#### 1. Keywords Don't Match
-
-**Check:**
-- Look at `promptTriggers.keywords` in skill-rules.json
-- Are the keywords actually in your prompt?
-- Remember: case-insensitive substring matching
-
-**Example:**
-```json
-"keywords": ["layout", "grid"]
-```
-- "how does the layout work?" β†’ βœ… Matches "layout"
-- "how does the grid system work?" β†’ βœ… Matches "grid"
-- "how do layouts work?" β†’ βœ… Matches "layout"
-- "how does it work?" β†’ ❌ No match
-
-**Fix:** Add more keyword variations to skill-rules.json
-
-#### 2. Intent Patterns Too Specific
-
-**Check:**
-- Look at `promptTriggers.intentPatterns`
-- Test regex at https://regex101.com/
-- May need broader patterns
-
-**Example:**
-```json
-"intentPatterns": [
- "(create|add).*?(database.*?table)" // Too specific
-]
-```
-- "create a database table" β†’ βœ… Matches
-- "add new table" β†’ ❌ Doesn't match (missing "database")
-
-**Fix:** Broaden the pattern:
-```json
-"intentPatterns": [
- "(create|add).*?(table|database)" // Better
-]
-```
-
-#### 3. Typo in Skill Name
-
-**Check:**
-- Skill name in SKILL.md frontmatter
-- Skill name in skill-rules.json
-- Must match exactly
-
-**Example:**
-```yaml
-# SKILL.md
-name: project-catalog-developer
-```
-```json
-// skill-rules.json
-"project-catalogue-developer": { // ❌ Typo: catalogue vs catalog
- ...
-}
-```
-
-**Fix:** Make names match exactly
-
-#### 4. JSON Syntax Error
-
-**Check:**
-```bash
-cat .claude/skills/skill-rules.json | jq .
-```
-
-If invalid JSON, jq will show the error.
-
-**Common errors:**
-- Trailing commas
-- Missing quotes
-- Single quotes instead of double
-- Unescaped characters in strings
-
-**Fix:** Correct JSON syntax, validate with jq
-
-#### Debug Command
-
-Test the hook manually:
-
-```bash
-echo '{"session_id":"debug","prompt":"your test prompt here"}' | \
- npx tsx .claude/hooks/skill-activation-prompt.ts
-```
-
-Expected: Your skill should appear in the output.
-
----
-
-### PreToolUse Not Blocking
-
-**Symptoms:** Edit a file that should trigger a guardrail, but no block occurs.
-
-**Common Causes:**
-
-#### 1. File Path Doesn't Match Patterns
-
-**Check:**
-- File path being edited
-- `fileTriggers.pathPatterns` in skill-rules.json
-- Glob pattern syntax
-
-**Example:**
-```json
-"pathPatterns": [
- "frontend/src/**/*.tsx"
-]
-```
-- Editing: `frontend/src/components/Dashboard.tsx` β†’ βœ… Matches
-- Editing: `frontend/tests/Dashboard.test.tsx` β†’ βœ… Matches (add exclusion!)
-- Editing: `backend/src/app.ts` β†’ ❌ Doesn't match
-
-**Fix:** Adjust glob patterns or add the missing path
-
-#### 2. Excluded by pathExclusions
-
-**Check:**
-- Are you editing a test file?
-- Look at `fileTriggers.pathExclusions`
-
-**Example:**
-```json
-"pathExclusions": [
- "**/*.test.ts",
- "**/*.spec.ts"
-]
-```
-- Editing: `services/user.test.ts` β†’ ❌ Excluded
-- Editing: `services/user.ts` β†’ βœ… Not excluded
-
-**Fix:** If test exclusion too broad, narrow it or remove
-
-#### 3. Content Pattern Not Found
-
-**Check:**
-- Does the file actually contain the pattern?
-- Look at `fileTriggers.contentPatterns`
-- Is the regex correct?
-
-**Example:**
-```json
-"contentPatterns": [
- "import.*[Pp]risma"
-]
-```
-- File has: `import { PrismaService } from './prisma'` β†’ βœ… Matches
-- File has: `import { Database } from './db'` β†’ ❌ Doesn't match
-
-**Debug:**
-```bash
-# Check if pattern exists in file
-grep -i "prisma" path/to/file.ts
-```
-
-**Fix:** Adjust content patterns or add missing imports
-
-#### 4. Session Already Used Skill
-
-**Check session state:**
-```bash
-ls .claude/hooks/state/
-cat .claude/hooks/state/skills-used-{session-id}.json
-```
-
-**Example:**
-```json
-{
- "skills_used": ["database-verification"],
- "files_verified": []
-}
-```
-
-If the skill is in `skills_used`, it won't block again in this session.
-
-**Fix:** Delete the state file to reset:
-```bash
-rm .claude/hooks/state/skills-used-{session-id}.json
-```
-
-#### 5. File Marker Present
-
-**Check file for skip marker:**
-```bash
-grep "@skip-validation" path/to/file.ts
-```
-
-If found, the file is permanently skipped.
-
-**Fix:** Remove the marker if verification is needed again
-
-#### 6. Environment Variable Override
-
-**Check:**
-```bash
-echo $SKIP_DB_VERIFICATION
-echo $SKIP_SKILL_GUARDRAILS
-```
-
-If set, the skill is disabled.
-
-**Fix:** Unset the environment variable:
-```bash
-unset SKIP_DB_VERIFICATION
-```
-
-#### Debug Command
-
-Test the hook manually:
-
-```bash
-cat <<'EOF' | npx tsx .claude/hooks/skill-verification-guard.ts 2>&1
-{
- "session_id": "debug",
- "tool_name": "Edit",
- "tool_input": {"file_path": "/root/git/your-project/form/src/services/user.ts"}
-}
-EOF
-echo "Exit code: $?"
-```
-
-Expected:
-- Exit code 2 + stderr message if should block
-- Exit code 0 + no output if should allow
-
----
-
-## False Positives
-
-**Symptoms:** Skill triggers when it shouldn't.
-
-**Common Causes & Solutions:**
-
-### 1. Keywords Too Generic
-
-**Problem:**
-```json
-"keywords": ["user", "system", "create"] // Too broad
-```
-- Triggers on: "user manual", "file system", "create directory"
-
-**Solution:** Make keywords more specific
-```json
-"keywords": [
- "user authentication",
- "user tracking",
- "create feature"
-]
-```
-
-### 2. Intent Patterns Too Broad
-
-**Problem:**
-```json
-"intentPatterns": [
- "(create)" // Matches everything with "create"
-]
-```
-- Triggers on: "create file", "create folder", "create account"
-
-**Solution:** Add context to patterns
-```json
-"intentPatterns": [
- "(create|add).*?(database|table|feature)" // More specific
-]
-```
-
-**Advanced:** Use negative lookaheads to exclude
-```regex
-(create)(?!.*test).*?(feature) // Don't match if "test" appears
-```
-
-### 3. File Paths Too Generic
-
-**Problem:**
-```json
-"pathPatterns": [
- "form/**" // Matches everything in form/
-]
-```
-- Triggers on: test files, config files, everything
-
-**Solution:** Use narrower patterns
-```json
-"pathPatterns": [
- "form/src/services/**/*.ts", // Only service files
- "form/src/controllers/**/*.ts"
-]
-```
-
-### 4. Content Patterns Catching Unrelated Code
-
-**Problem:**
-```json
-"contentPatterns": [
- "Prisma" // Matches in comments, strings, etc.
-]
-```
-- Triggers on: `// Don't use Prisma here`
-- Triggers on: `const note = "Prisma is cool"`
-
-**Solution:** Make patterns more specific
-```json
-"contentPatterns": [
- "import.*[Pp]risma", // Only imports
- "PrismaService\\.", // Only actual usage
- "prisma\\.(findMany|create)" // Specific methods
-]
-```
-
-### 5. Adjust Enforcement Level
-
-**Last resort:** If false positives are frequent:
-
-```json
-{
- "enforcement": "block" // Change to "suggest"
-}
-```
-
-This makes it advisory instead of blocking.
-
----
-
-## Hook Not Executing
-
-**Symptoms:** Hook doesn't run at all - no suggestion, no block.
-
-**Common Causes:**
-
-### 1. Hook Not Registered
-
-**Check `.claude/settings.json`:**
-```bash
-cat .claude/settings.json | jq '.hooks.UserPromptSubmit'
-cat .claude/settings.json | jq '.hooks.PreToolUse'
-```
-
-Expected: Hook entries present
-
-**Fix:** Add missing hook registration:
-```json
-{
- "hooks": {
- "UserPromptSubmit": [
- {
- "hooks": [
- {
- "type": "command",
- "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/skill-activation-prompt.sh"
- }
- ]
- }
- ]
- }
-}
-```
-
-### 2. Bash Wrapper Not Executable
-
-**Check:**
-```bash
-ls -l .claude/hooks/*.sh
-```
-
-Expected: `-rwxr-xr-x` (executable)
-
-**Fix:**
-```bash
-chmod +x .claude/hooks/*.sh
-```
-
-### 3. Incorrect Shebang
-
-**Check:**
-```bash
-head -1 .claude/hooks/skill-activation-prompt.sh
-```
-
-Expected: `#!/bin/bash`
-
-**Fix:** Add correct shebang to first line
-
-### 4. npx/tsx Not Available
-
-**Check:**
-```bash
-npx tsx --version
-```
-
-Expected: Version number
-
-**Fix:** Install dependencies:
-```bash
-cd .claude/hooks
-npm install
-```
-
-### 5. TypeScript Compilation Error
-
-**Check:**
-```bash
-cd .claude/hooks
-npx tsc --noEmit skill-activation-prompt.ts
-```
-
-Expected: No output (no errors)
-
-**Fix:** Correct TypeScript syntax errors
-
----
-
-## Performance Issues
-
-**Symptoms:** Hooks are slow, noticeable delay before prompt/edit.
-
-**Common Causes:**
-
-### 1. Too Many Patterns
-
-**Check:**
-- Count patterns in skill-rules.json
-- Each pattern = regex compilation + matching
-
-**Solution:** Reduce patterns
-- Combine similar patterns
-- Remove redundant patterns
-- Use more specific patterns (faster matching)
-
-### 2. Complex Regex
-
-**Problem:**
-```regex
-(create|add|modify|update|implement|build).*?(feature|endpoint|route|service|controller|component|UI|page)
-```
-- Long alternations = slow
-
-**Solution:** Simplify
-```regex
-(create|add).*?(feature|endpoint) // Fewer alternatives
-```
-
-### 3. Too Many Files Checked
-
-**Problem:**
-```json
-"pathPatterns": [
- "**/*.ts" // Checks ALL TypeScript files
-]
-```
-
-**Solution:** Be more specific
-```json
-"pathPatterns": [
- "form/src/services/**/*.ts", // Only specific directory
- "form/src/controllers/**/*.ts"
-]
-```
-
-### 4. Large Files
-
-Content pattern matching reads entire file - slow for large files.
-
-**Solution:**
-- Only use content patterns when necessary
-- Consider file size limits (future enhancement)
-
-### Measure Performance
-
-```bash
-# UserPromptSubmit
-time echo '{"prompt":"test"}' | npx tsx .claude/hooks/skill-activation-prompt.ts
-
-# PreToolUse
-time cat <<'EOF' | npx tsx .claude/hooks/skill-verification-guard.ts
-{"tool_name":"Edit","tool_input":{"file_path":"test.ts"}}
-EOF
-```
-
-**Target metrics:**
-- UserPromptSubmit: < 100ms
-- PreToolUse: < 200ms
-
----
-
-**Related Files:**
-- [SKILL.md](SKILL.md) - Main skill guide
-- [HOOK_MECHANISMS.md](HOOK_MECHANISMS.md) - How hooks work
-- [SKILL_RULES_REFERENCE.md](SKILL_RULES_REFERENCE.md) - Configuration reference
diff --git a/.claude/skills/skill-rules.json b/.claude/skills/skill-rules.json
deleted file mode 100644
index 657e191835..0000000000
--- a/.claude/skills/skill-rules.json
+++ /dev/null
@@ -1,131 +0,0 @@
-{
- "version": "1.0",
- "description": "Skill activation triggers for Claude Code. Controls when skills automatically suggest or block actions.",
- "skills": {
- "skill-developer": {
- "type": "domain",
- "enforcement": "suggest",
- "priority": "high",
- "description": "Meta-skill for creating and managing Claude Code skills",
- "promptTriggers": {
- "keywords": [
- "skill system",
- "create skill",
- "add skill",
- "skill triggers",
- "skill rules",
- "hook system",
- "skill development",
- "skill-rules.json"
- ],
- "intentPatterns": [
- "(how do|how does|explain).*?skill",
- "(create|add|modify|build).*?skill",
- "skill.*?(work|trigger|activate|system)"
- ]
- }
- },
-"add-model-price": {
- "type": "domain",
- "enforcement": "suggest",
- "priority": "high",
- "description": "Guide for adding LLM model pricing entries to default-model-prices.json",
- "promptTriggers": {
- "keywords": [
- "model price",
- "model pricing",
- "model prices",
- "add model",
- "new model",
- "model cost",
- "default-model-prices",
- "matchPattern",
- "pricingTiers",
- "pricing tier",
- "token pricing",
- "Claude pricing",
- "OpenAI pricing",
- "Anthropic pricing",
- "Gemini pricing",
- "Bedrock pricing",
- "Vertex pricing"
- ],
- "intentPatterns": [
- "(add|create|insert|update).*?(model|pricing|price)",
- "(new|add).*?(claude|openai|anthropic|gemini|gpt).*?(model|price)",
- "model.*?(price|pricing|cost)",
- "pricing.*?tier"
- ]
- },
- "fileTriggers": {
- "pathPatterns": [
- "worker/src/constants/default-model-prices.json",
- "packages/shared/src/server/llm/types.ts",
- "**/model*price*.json"
- ],
- "contentPatterns": [
- "matchPattern",
- "pricingTiers",
- "tokenizerId",
- "anthropicModels",
- "openAIModels"
- ]
- }
- },
- "backend-dev-guidelines": {
- "type": "domain",
- "enforcement": "suggest",
- "priority": "high",
- "description": "Backend development patterns for Node.js/NextJS/Express/TypeScript",
- "promptTriggers": {
- "keywords": [
- "backend",
- "backend development",
- "microservice",
- "controller",
- "service",
- "repository",
- "route",
- "routing",
- "express",
- "API",
- "endpoint",
- "middleware",
- "validation",
- "Zod",
- "Prisma",
- "database access",
- "BaseController",
- "dependency injection",
- "unifiedConfig",
- "configuration"
- ],
- "intentPatterns": [
- "(create|add|implement|build).*?(route|endpoint|API|controller|service|repository)",
- "(fix|handle|debug).*?(error|exception|backend)",
- "(add|implement).*?(middleware|validation|error.*?handling)",
- "(organize|structure|refactor).*?(backend|service|API)",
- "(how to|best practice).*?(backend|route|controller|service)"
- ]
- },
- "fileTriggers": {
- "pathPatterns": [
- "worker/src/**/*.ts",
- "packages/shared/src/**/*.ts",
- "web/src/**/*.ts"
- ],
- "pathExclusions": [
- "**/*.test.ts",
- "**/*.spec.ts"
- ],
- "contentPatterns": [
- "router\\.",
- "app\\.(get|post|put|delete|patch)",
- "export.*Controller",
- "export.*Service",
- "prisma\\."
- ]
- }
- }
- }
-}
\ No newline at end of file
diff --git a/.cursor/rules/tests.mdc b/.cursor/rules/tests.mdc
index c32a800da1..d2afb9c83f 100644
--- a/.cursor/rules/tests.mdc
+++ b/.cursor/rules/tests.mdc
@@ -6,4 +6,4 @@ alwaysApply: true
# Writing tests
- When writing tests, focus on decoupling each `it` or `test` block to ensure that they can run independently and concurrently. Tests must never depend on the action or outcome of previous or subsequent tests.
-- When writing tests, especially in the __tests__/server directory, ensure that you avoid `pruneDatabase` calls.
+- When writing tests, especially in `__tests__/server`, prefer scoped cleanup or unique test data over global reset helpers.
diff --git a/AGENTS.md b/AGENTS.md
index 6d5cf19ad8..a4c5090791 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -5,15 +5,24 @@ evaluating, and debugging AI applications.
Langfuse monorepo guidance for fast, safe code changes.
## Maintenance Contract
+
- `AGENTS.md` is a living document.
- Update this file in the same PR when monorepo-level architecture, workflows,
dependency boundaries, mandatory verification commands, or release/security
processes materially change.
+- Update this file when user feedback adds a durable repo-level instruction that
+ future agents should follow. Update the relevant shared skill files under
+ `.agents/skills/` as well when that feedback changes a reusable workflow,
+ checklist, or decision rule that those skills should teach. Treat feedback as
+ durable when it changes the default workflow, review expectations, naming
+ rules, verification rules, or handoff conventions for future tasks. Do not
+ edit `AGENTS.md` or shared skills for one-off task preferences.
- For package-local material changes, update the package-local `AGENTS.md` in
the same PR.
-- If no material guidance changed, do not edit AGENTS files.
+- If no material guidance changed, do not edit AGENTS files or shared skills.
## Project Structure & Module Organization
+
```text
langfuse/
β”œβ”€ web/ # Next.js app (UI + tRPC + public REST)
@@ -37,8 +46,25 @@ langfuse/
- `@langfuse/shared` -> no imports from `web`, `worker`, or `ee`
- Queue payload schemas and queue-name contracts are owned by
`packages/shared/src/server/queues.ts`.
+- Shared package import surfaces:
+ - `@langfuse/shared`: client-safe/shared contracts, types, schemas, and
+ reusable utilities
+ - `@langfuse/shared/src/server`: server-only shared services, repositories,
+ queue helpers, logging, ingestion, auth, and runtime helpers
+ - `@langfuse/shared/src/db`: Prisma client singleton plus Prisma types
+ - `@langfuse/shared/src/env`, `@langfuse/shared/encryption`: focused env and
+ encryption helpers
+ - See `packages/shared/AGENTS.md` for the full export map and when to use
+ each entrypoint
+- Architecture handbook:
+ [langfuse.com/handbook/product-engineering/architecture](https://langfuse.com/handbook/product-engineering/architecture)
+ with source markdown in
+ `../langfuse-docs/content/handbook/product-engineering/architecture.mdx`
+ (GitHub mirror:
+ [architecture.mdx](https://github.com/langfuse/langfuse-docs/blob/4188c1ba453240c90a763a8067ef442d68839323/content/handbook/product-engineering/architecture.mdx#L4))
## Build, Test, and Development Commands
+
- Install deps: `pnpm install`
- Dev all packages: `pnpm run dev`
- Dev web only: `pnpm run dev:web`
@@ -62,6 +88,7 @@ Minimum verification matrix:
| Cross-package refactor (`web` + `worker` + `shared`) | `pnpm run lint` + `pnpm run typecheck` + targeted tests per impacted package |
## Coding Style & Naming Conventions
+
- Keep changes scoped; avoid unrelated refactors.
- Prefer package-local implementation details in package AGENTS files.
- Do not hand-edit generated/build artifacts:
@@ -72,29 +99,49 @@ Minimum verification matrix:
- `packages/shared/prisma/generated/*`
## Testing Guidelines
+
- Keep each test independent and parallel-safe.
-- `web/src/__tests__/server`: avoid `pruneDatabase` calls.
+- Implement automated tests for every new feature and for material feature
+ behavior changes. If a test is genuinely not feasible, document the reason in
+ the PR description.
- Client tests contain `....clienttest.ts`
- When you write a test for a bug or similar, write the test that fails first. Check that it fails. Only then fix the bug. Otherwise, the test is not good!
## Commit & Pull Request Guidelines
-- Commit messages and PR titles must follow Conventional Commits: `type(scope): description` or `type: description`.
+
+- Commit messages and PR titles must follow Conventional Commits:
+ `type(scope): description` or `type: description`.
+- Use a lowercase conventional type such as `feat`, `fix`, `docs`, `refactor`,
+ `chore`, or `test`; keep the description concise and imperative.
- PR titles are validated by `.github/workflows/validate-pr-title.yml`.
+- Reference: https://www.conventionalcommits.org/en/v1.0.0/
- Include AGENTS.md updates in the same PR when guidance materially changes.
- In PR descriptions, list impacted packages and executed verification commands.
## Docs Linking
+
- Public API contract changes must update Fern sources in `fern/apis/**` and regenerated outputs; do not hand-edit `generated/**`.
- Use repo-relative file paths in docs and runbooks.
- Our docs live in `../langfuse-docs/` which is a different repo. You may always access this.
## Agent-specific Notes
+
- Root `AGENTS.md` is monorepo-level only.
- Package-local runbooks, commands, and entry points belong in package `AGENTS.md` files.
- Keep guidance DRY: canonicalize to the most specific file.
+- `CLAUDE.md` is the Claude Code entrypoint for this repo and should stay as a thin shim that points back to this file.
- Repo-owned Codex cloud bootstrap lives in `scripts/codex/setup.sh` and `scripts/codex/maintenance.sh`; contributors still configure the actual environment in the Codex UI.
+- Codex may create or refine shared skills under `.agents/skills/` when a repeated repo-specific workflow would help future agents. Keep shared skills tool-neutral and scoped to durable guidance.
+- Shared skill index: [`.agents/skills/README.md`](.agents/skills/README.md)
+- Shared skills use a short `SKILL.md` entrypoint and should prefer focused `references/` docs and `scripts/` helpers over large compiled guides. Keep any local `AGENTS.md` concise and use it as a router, not a dump of all details.
+- If a task matches one of the shared skill scopes below, read the linked `SKILL.md` before editing code, then follow its local references as needed:
+ - Backend and API work in `web/src/server/**`, `web/src/pages/api/public/**`, `worker/src/**`, or `packages/shared/src/**`: [`.agents/skills/backend-dev-guidelines/SKILL.md`](.agents/skills/backend-dev-guidelines/SKILL.md)
+ - Model pricing work in `worker/src/constants/default-model-prices.json`, `packages/shared/src/server/llm/types.ts`, or related pricing files: [`.agents/skills/add-model-price/SKILL.md`](.agents/skills/add-model-price/SKILL.md)
+- If more than one skill matches, read the minimal set required.
+- For completed feature branches that need a changelog entry, use [`.claude/agents/changelog-writer.md`](.claude/agents/changelog-writer.md).
## Release Channel
+
- Release workflow is managed at root (`pnpm run release`).
- Langfuse Cloud deployments are triggered by pushes to `production` (`.github/workflows/deploy.yml`).
- Promote `main` to `production` via `.github/workflows/promote-main-to-production.yml` (manual `workflow_dispatch`).
@@ -102,25 +149,31 @@ Minimum verification matrix:
- Do not change release/versioning flow without updating this file and impacted package guides.
## GitHub Search
+
- use the github cli `gh search issues` to search github.
## GitHub Issues and Pull Requests
+
- Placeholder: add issue triage and PR hygiene conventions used by maintainers.
## Security and Configuration Tips
+
- Never commit secrets or credentials.
- Keep examples in `.env*.example` files in sync with required env vars.
- Follow `SECURITY.md` for vulnerability reporting/handling.
## Troubleshooting
+
- Lint/typecheck failures: run `pnpm run lint` and `pnpm run tc`.
- Schema/client drift: run `pnpm run db:generate`.
- Local infra issues: run `pnpm run infra:dev:up`; use `pnpm run dx` only when destructive reset is intended.
## Git Notes
+
- Do not use destructive git commands (for example `reset --hard`) unless explicitly requested.
- Do not revert unrelated working-tree changes.
- Keep commits focused and atomic.
## Cursor Rules
+
- Additional folder-specific rules live in `.cursor/rules/`.
diff --git a/CLAUDE.md b/CLAUDE.md
index 4fd09034eb..577fe91e88 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -1,214 +1,20 @@
# CLAUDE.md
-## Project Overview
-
-Langfuse is an open-source LLM engineering platform that helps teams collaboratively develop, monitor, evaluate, and debug AI applications.
-The main feature areas are tracing, evals and prompt management. Langfuse consists of the web application (this repo), documentation, python SDK and javascript/typescript SDK.
-This repo contains the web application, worker, and supporting packages but notably not the JS nor Python client SDKs.
-
-## Repository Structure
-High level structure. There are more folders (eg for hooks etc).
-```
-langfuse/
-β”œβ”€β”€ web/ # Next.js 14 frontend/backend application
-β”‚ β”œβ”€β”€ src/
-β”‚ β”‚ β”œβ”€β”€ components/ # Reusable UI components (shadcn/ui)
-β”‚ β”‚ β”œβ”€β”€ features/ # Feature-specific code organized by domain
-β”‚ β”‚ β”œβ”€β”€ pages/ # Next.js pages (Pages Router)
-β”‚ β”‚ └── server/ # tRPC API routes and server logic
-β”‚ └── public/ # Static assets
-β”œβ”€β”€ worker/ # Express.js background job processor
-β”‚ └── src/
-β”‚ β”œβ”€β”€ queues/ # BullMQ job queues
-β”‚ └── services/ # Background processing services
-β”œβ”€β”€ packages/
-β”‚ β”œβ”€β”€ shared/ # Shared types, schemas, and utilities
-β”‚ β”‚ β”œβ”€β”€ prisma/ # Database schema and migrations
-β”‚ β”‚ └── src/ # Shared TypeScript code
-β”‚ β”œβ”€β”€ config-eslint/ # ESLint configuration
-β”‚ └── config-typescript/ # TypeScript configuration
-β”œβ”€β”€ ee/ # Enterprise Edition features
-β”œβ”€β”€ fern/ # API documentation and OpenAPI specs
-β”œβ”€β”€ generated/ # Auto-generated client code
-└── scripts/ # Development and deployment scripts
-```
-
-## Repository Architecture
-This is a **pnpm + Turbo monorepo** with the following key packages:
-
-### Core Applications
-- **`/web/`** - Next.js 14 application (Pages Router) providing both frontend UI and backend APIs
-- **`/worker/`** - Express.js background job processing server
-- **`/packages/shared/`** - Shared database schema, types, and utilities
-
-### Supporting Packages
-- **`/ee/`** - Enterprise Edition features (separate licensing)
-- **`/packages/config-eslint/`** - Shared ESLint configuration
-- **`/packages/config-typescript/`** - Shared TypeScript configuration
-
-## Development Commands
-
-### Development
-```sh
-pnpm i # Install dependencies
-pnpm run dev # Start all services (web + worker)
-pnpm run dev:web # Web app only (localhost:3000) - **used in most cases!**
-pnpm run dev:worker # Worker only
-pnpm run dx # Full initial setup: install deps, reset DBs, resets node modules, seed data, start dev. USE SPARINGLY AS IT WIPES THE DATABASE & node_modules
-```
-
-### Database Management
-database commands are to be run in the `packages/shared/` folder.
-```sh
-pnpm run db:generate # Build prisma models
-pnpm run db:migrate # Run Prisma migrations
-pnpm run db:reset # Reset and reseed databases
-pnpm run db:seed # Seed with example data
-```
-
-### Infrastructure
-```sh
-pnpm run infra:dev:up # Start Docker services (PostgreSQL, ClickHouse, Redis, MinIO)
-pnpm run infra:dev:down # Stop Docker services
-```
-
-### Building & Type Checking
-```sh
-pnpm --filter=PACKAGE_NAME run build # Runs the build command, will show real typescript errors etc.
-pnpm tc # Fast typecheck across all packages (alias for pnpm typecheck)
-pnpm build:check # Full Next.js build to alternate dir (can run parallel with dev server)
-```
-
-### Testing in Web Package
-The web package uses JEST for unit tests.
-`web` related tests must go into the `web/src/__tests__/` folder.
-```sh
-pnpm test --testPathPatterns="$FILE_LOCATION_PATTERN" --testNamePattern="$TEST_NAME_PATTERN"
-# For client tests:
-pnpm test-client --testPathPatterns="buildStepData" --testNamePattern="buildStepData"
-```
-
-### Testing in the Worker Package
-The worker uses `vitest` for unit tests.
-```sh
-pnpm run test --filter=worker -- $TEST_FILE_NAME -t "$TEST_NAME"
-```
-
-### Utilities
-```bash
-pnpm run format # Format code across entire project
-pnpm run nuke # Remove all node_modules, build files, wipe database, docker containers. **USE WITH CAUTION**
-```
-
-## Technology Stack
-
-### Web Application (`/web/`)
-- **Framework**: Next.js 14 (Pages Router)
-- **APIs**: tRPC (type-safe client-server communication) + REST APIs for public access
-- **Authentication**: NextAuth.js/Auth.js
-- **Database**: Prisma ORM with PostgreSQL
-- **Analytics Database**: ClickHouse (high-volume trace data)
-- **Validation**: Zod schemas, we use zodv4 (always import from `zod/v4`)
-- **Styling**: Tailwind CSS with CSS variables for theming
-- **Components**: shadcn/ui (Radix UI primitives)
-- **State Management**: TanStack Query (React Query) + tRPC
-- **Charts**: Recharts
-
-### Worker Application (`/worker/`)
-- **Framework**: Express.js
-- **Queue System**: BullMQ with Redis
-- **Purpose**: Async processing (data ingestion, evaluations, exports, integrations)
-
-### Infrastructure
-- **Primary Database**: PostgreSQL (via Prisma ORM)
-- **Analytics Database**: ClickHouse
-- **Cache/Queues**: Redis
-- **Blob Storage**: MinIO/S3
-
-## Development Guidelines
-
-### Frontend Features
-- All new features go in `/web/src/features/[feature-name]/`
-- Use tRPC for full-stack features (entry point: `web/src/server/api/root.ts`)
-- Follow existing feature structure for consistency
-- Use shadcn/ui components from `@/src/components/ui`
-- Custom reusable components go in `@/src/components`
-
-### Public API Development
-- All public API routes in `/web/src/pages/api/public`
-- Use `withMiddlewares.ts` wrapper
-- Define types in `/web/src/features/public-api/types` with strict Zod v4 objects
-- Add end-to-end tests (see `datasets-api.servertest.ts`)
-- Manually update Fern API specs in `/fern/`, then regenerate OpenAPI spec via Fern CLI
-
-### Authorization & RBAC
-- Check `/web/src/features/rbac/README.md` for authorization patterns
-- Implement proper entitlements checking (see `/web/src/features/entitlements/README.md`)
-
-### Database
-- **Dual database system**: PostgreSQL (primary) + ClickHouse (analytics)
-- Use `golang-migrate` CLI for database migrations
-- All database operations go through Prisma ORM for PostgreSQL
-- Foreign key relationships may not be enforced in schema to allow unordered ingestion
-
-### Testing
-- Jest for API tests, Playwright for E2E tests
-- For backend/API changes, tests must pass before pushes
-- Add tests for new API endpoints and features
-- When writing tests, focus on decoupling each `it` or `test` block to ensure that they can run independently and concurrently. Tests must never depend on the action or outcome of previous or subsequent tests.
-- When writing tests, especially in the __tests__/server directory, ensure that you avoid `pruneDatabase` calls.
-
-### Code Conventions
-- **Pages Router** (not App Router)
-- Commit messages and PR titles must follow Conventional Commits (`type(scope): description` or `type: description`); PR titles are validated in `.github/workflows/validate-pr-title.yml`
-- Use CSS variables for theming (supports auto dark/light mode)
-- TypeScript throughout
-- Zod v4 for all input validation
-
-## Environment Setup
-
-- **Node.js**: Version 24 (specified in `.nvmrc`)
-- **Package Manager**: pnpm v9.5.0
-- **Database Dependencies**: Docker for local PostgreSQL, ClickHouse, Redis, MinIO
-- **Environment**: Copy `.env.dev.example` to `.env`
-
-## Login for Development
-
-When running locally with seed data:
-- Username: `[email protected]`
-- Password: `password`
-- Demo project URL: `http://localhost:3000/project/7a88fb47-b4e2-43b8-a06c-a5ce950dc53a`
-
-## Linear MCP
-To get a project, use the `get_project` capability with the full project name as it is in the title.
-- bad: message-placeholder-in-chat-messages-2beb6f02ec48
-- good: Message placeholder in chat messages
-
-## Front-end Tips
-
-### Window Location Handling
-- Whenever you want to use or do use window.location..., ensure that you also add proper handling for a custom basePath
-
-## TypeScript Best Practices
-- In TypeScript, if possible, don't use the `any` type
-- **Use a single params object for functions with multiple arguments** - This makes code more readable at call sites and prevents bugs when arguments of the same type are accidentally swapped:
-
-```typescript
-// ❌ Bad - positional arguments are unclear and can be swapped without type errors
-function sendMessage(userId: string, sessionId: string, projectId: string) {
- // ...
-}
-sendMessage(someString, someOtherString, anotherString); // Which is which?
-
-// βœ… Good - params object makes intent clear and prevents argument swapping
-function sendMessage(params: { userId: string; sessionId: string; projectId: string }) {
- // ...
-}
-sendMessage({ userId: someString, sessionId: someOtherString, projectId: anotherString });
-```
-
-## General Coding Guidelines
-- For easier code reviews, prefer not to move functions etc around within a file unless necessary or instructed to do so
-
-## Development Tips
-- Before trying to build the package, try running the linter once first
+Claude Code should treat this file as the repo entrypoint, but the canonical
+shared instructions live in @AGENTS.md.
+
+Start here:
+- Read @AGENTS.md for monorepo structure, verification requirements, and shared
+ workflow rules.
+- When working in `web/`, `worker/`, `packages/shared/`, or `ee/`, also read
+ the closest package-local `AGENTS.md`.
+
+Repo-local skills:
+- Shared skill index: @.agents/skills/README.md
+- Shared skills start in `SKILL.md` and may route to a local `AGENTS.md`,
+ `references/`, or `scripts/` files.
+- Backend work: @.agents/skills/backend-dev-guidelines/SKILL.md
+- Model pricing updates: @.agents/skills/add-model-price/SKILL.md
+
+Specialized agent:
+- Changelog entries for completed features: @.claude/agents/changelog-writer.md
diff --git a/packages/shared/AGENTS.md b/packages/shared/AGENTS.md
index c5ab2e7eb0..e1aad3bd99 100644
--- a/packages/shared/AGENTS.md
+++ b/packages/shared/AGENTS.md
@@ -34,6 +34,42 @@ Use root [AGENTS.md](../../AGENTS.md) for monorepo-level rules.
- ClickHouse migrations: `clickhouse/migrations/{clustered,unclustered}/*`
- Seeder and support scripts: `scripts/seeder/*`, `clickhouse/scripts/*`
+## Export Entry Points
+
+- `@langfuse/shared` via `src/index.ts`: default shared surface for
+ cross-runtime types, zod schemas, table definitions, domain models, prompt
+ helpers, eval/model-pricing helpers, and other frontend-safe utilities.
+- `@langfuse/shared/src/server` via `src/server/index.ts`: server-only barrel
+ for shared backend services, repositories, queue helpers/contracts, Redis and
+ ClickHouse helpers, auth helpers, logger/instrumentation, ingestion helpers,
+ LLM execution helpers, and server test utilities.
+- `@langfuse/shared/src/db` via `src/db.ts`: Prisma client singleton plus
+ Prisma namespace/types for direct database access. Never route this into
+ frontend-safe code.
+- `@langfuse/shared/src/env` via `src/env.ts`: validated shared environment
+ schema/accessors used by backend runtimes and scripts.
+- `@langfuse/shared/encryption` via `src/encryption/index.ts`: encryption and
+ signature helpers for secrets and signed payloads.
+- Narrower exported subpaths also exist for targeted imports:
+ `@langfuse/shared/src/server/auth/apiKeys`,
+ `@langfuse/shared/src/server/ee/ingestionMasking`, and
+ `@langfuse/shared/src/utils/chatml`.
+
+When changing export surfaces, keep `package.json#exports`, the relevant barrel
+file (`src/index.ts`, `src/server/index.ts`, etc.), and this guide aligned in
+the same PR.
+
+## Architecture Handbook
+
+- For the cross-package system view, read the architecture handbook:
+ [langfuse.com/handbook/product-engineering/architecture](https://langfuse.com/handbook/product-engineering/architecture).
+- Source markdown lives in
+ `../langfuse-docs/content/handbook/product-engineering/architecture.mdx`
+ (GitHub mirror:
+ [architecture.mdx](https://github.com/langfuse/langfuse-docs/blob/4188c1ba453240c90a763a8067ef442d68839323/content/handbook/product-engineering/architecture.mdx#L4)).
+- Consult it when changing shared contracts that affect the web container,
+ worker container, ingestion flow, or storage-layer boundaries.
+
## Quick Commands
- Dev watch build: `pnpm --filter @langfuse/shared run dev`
@@ -74,6 +110,19 @@ Use root [AGENTS.md](../../AGENTS.md) for monorepo-level rules.
the shard-aware queue callers in `web` and `worker` aligned with the shared
helper API.
+### Export surface change
+
+1. Decide whether the symbol belongs in the client-safe root barrel, the
+ server-only barrel, or a narrower subpath export.
+2. Update the owning file (`src/index.ts`, `src/server/index.ts`, `src/db.ts`,
+ `src/env.ts`, or another explicit subpath).
+3. Update `package.json#exports` if the public import path changed or a new
+ subpath is required.
+4. Update import sites in `web`, `worker`, and `ee` to use the intended
+ entrypoint.
+5. Update this file and any consuming package `AGENTS.md` guidance when the
+ recommended import path changes.
+
## Package-Specific Rules
- Keep backward compatibility in queue payloads when possible during rolling
diff --git a/web/.claude/skills/vercel-composition-patterns b/web/.claude/skills/vercel-composition-patterns
deleted file mode 120000
index 55a19e8f46..0000000000
--- a/web/.claude/skills/vercel-composition-patterns
+++ /dev/null
@@ -1 +0,0 @@
-../../.agents/skills/vercel-composition-patterns
\ No newline at end of file
diff --git a/web/.claude/skills/vercel-react-best-practices b/web/.claude/skills/vercel-react-best-practices
deleted file mode 120000
index e567923b32..0000000000
--- a/web/.claude/skills/vercel-react-best-practices
+++ /dev/null
@@ -1 +0,0 @@
-../../.agents/skills/vercel-react-best-practices
\ No newline at end of file
diff --git a/web/AGENTS.md b/web/AGENTS.md
index 3387f867a6..bda5496643 100644
--- a/web/AGENTS.md
+++ b/web/AGENTS.md
@@ -29,6 +29,39 @@ Use root [AGENTS.md](../AGENTS.md) for monorepo-level rules.
- Client tests: `src/**/*.clienttest.ts(x)`
- E2E: `src/__e2e__/*`
+## Shared Package Imports
+
+- Prefer `@langfuse/shared` in frontend-safe web code for shared types, zod
+ schemas, domain contracts, table definitions, prompt/eval/model-pricing
+ helpers, and other cross-runtime utilities.
+- Use `@langfuse/shared/src/server` only from server-only web code such as
+ `src/server/**`, `src/pages/api/**`, and server tests.
+- Use `@langfuse/shared/src/db` only in backend or test code that needs direct
+ Prisma access; never route it into client bundles.
+- Use narrower subpaths such as `@langfuse/shared/src/env` or
+ `@langfuse/shared/encryption` only when that focused surface is the clearest
+ dependency.
+- See `../packages/shared/AGENTS.md` for the full shared export map and what
+ each entrypoint contains.
+- For the higher-level platform topology across web, worker, Postgres,
+ ClickHouse, Redis, and S3, also read the architecture handbook:
+ [langfuse.com/handbook/product-engineering/architecture](https://langfuse.com/handbook/product-engineering/architecture)
+ with source markdown in
+ `../langfuse-docs/content/handbook/product-engineering/architecture.mdx`
+ (GitHub mirror:
+ [architecture.mdx](https://github.com/langfuse/langfuse-docs/blob/4188c1ba453240c90a763a8067ef442d68839323/content/handbook/product-engineering/architecture.mdx#L4)).
+
+## Package-Local Skills
+
+- React composition and component API design:
+ [`web/.agents/skills/vercel-composition-patterns/SKILL.md`](.agents/skills/vercel-composition-patterns/SKILL.md)
+- React/Next.js performance and rendering best practices:
+ [`web/.agents/skills/vercel-react-best-practices/SKILL.md`](.agents/skills/vercel-react-best-practices/SKILL.md)
+
+Read these package-local skills before substantial frontend refactors when the
+task involves component composition, reusable component APIs, rendering
+performance, bundle size, or React/Next.js performance patterns.
+
## Quick Commands
- Dev: `pnpm --filter web run dev`
- Lint: `pnpm --filter web run lint`
@@ -63,8 +96,5 @@ Use root [AGENTS.md](../AGENTS.md) for monorepo-level rules.
## Package-Specific Rules
- Router style is Pages Router-centric; follow existing routing patterns.
- Keep tests independent; no reliance on test execution order.
-- In `src/__tests__/server`, avoid `pruneDatabase` calls.
- Confirm the target `*.clienttest.*` or `*.servertest.*` file exists before using `--testPathPatterns`; source files do not always have a matching colocated test file.
- Do not hand-edit build artifacts: `.next/*`, `.next-check/*`, `dist/*`.
-
-<!-- NEXT-AGENTS-MD-START -->[Next.js Docs Index]|root: ./.next-docs|STOP. What you remember about Next.js is WRONG for this project. Always search docs and read before any task.|If docs missing, run this command first: npx @next/codemod agents-md --output AGENTS.md|01-app:{04-glossary.mdx}|01-app/01-getting-started:{01-installation.mdx,02-project-structure.mdx,03-layouts-and-pages.mdx,04-linking-and-navigating.mdx,05-server-and-client-components.mdx,06-fetching-data.mdx,07-mutating-data.mdx,08-caching.mdx,09-revalidating.mdx,10-error-handling.mdx,11-css.mdx,12-images.mdx,13-fonts.mdx,14-metadata-and-og-images.mdx,15-route-handlers.mdx,16-proxy.mdx,17-deploying.mdx,18-upgrading.mdx}|01-app/02-guides:{ai-agents.mdx,analytics.mdx,authentication.mdx,backend-for-frontend.mdx,caching-without-cache-components.mdx,ci-build-caching.mdx,content-security-policy.mdx,css-in-js.mdx,custom-server.mdx,data-security.mdx,debugging.mdx,draft-mode.mdx,environment-variables.mdx,forms.mdx,incremental-static-regeneration.mdx,instant-navigation.mdx,instrumentation.mdx,internationalization.mdx,json-ld.mdx,lazy-loading.mdx,local-development.mdx,mcp.mdx,mdx.mdx,memory-usage.mdx,migrating-to-cache-components.mdx,multi-tenant.mdx,multi-zones.mdx,open-telemetry.mdx,package-bundling.mdx,prefetching.mdx,preserving-ui-state.mdx,production-checklist.mdx,progressive-web-apps.mdx,public-static-pages.mdx,redirecting.mdx,sass.mdx,scripts.mdx,self-hosting.mdx,single-page-applications.mdx,static-exports.mdx,streaming.mdx,tailwind-v3-css.mdx,third-party-libraries.mdx,videos.mdx}|01-app/02-guides/migrating:{app-router-migration.mdx,from-create-react-app.mdx,from-vite.mdx}|01-app/02-guides/testing:{cypress.mdx,jest.mdx,playwright.mdx,vitest.mdx}|01-app/02-guides/upgrading:{codemods.mdx,version-14.mdx,version-15.mdx,version-16.mdx}|01-app/03-api-reference:{07-edge.mdx,08-turbopack.mdx}|01-app/03-api-reference/01-directives:{use-cache-private.mdx,use-cache-remote.mdx,use-cache.mdx,use-client.mdx,use-server.mdx}|01-app/03-api-reference/02-components:{font.mdx,form.mdx,image.mdx,link.mdx,script.mdx}|01-app/03-api-reference/03-file-conventions/01-metadata:{app-icons.mdx,manifest.mdx,opengraph-image.mdx,robots.mdx,sitemap.mdx}|01-app/03-api-reference/03-file-conventions/02-route-segment-config:{dynamicParams.mdx,instant.mdx,maxDuration.mdx,preferredRegion.mdx,runtime.mdx}|01-app/03-api-reference/03-file-conventions:{default.mdx,dynamic-routes.mdx,error.mdx,forbidden.mdx,instrumentation-client.mdx,instrumentation.mdx,intercepting-routes.mdx,layout.mdx,loading.mdx,mdx-components.mdx,not-found.mdx,page.mdx,parallel-routes.mdx,proxy.mdx,public-folder.mdx,route-groups.mdx,route.mdx,src-folder.mdx,template.mdx,unauthorized.mdx}|01-app/03-api-reference/04-functions:{after.mdx,cacheLife.mdx,cacheTag.mdx,catchError.mdx,connection.mdx,cookies.mdx,draft-mode.mdx,fetch.mdx,forbidden.mdx,generate-image-metadata.mdx,generate-metadata.mdx,generate-sitemaps.mdx,generate-static-params.mdx,generate-viewport.mdx,headers.mdx,image-response.mdx,next-request.mdx,next-response.mdx,not-found.mdx,permanentRedirect.mdx,redirect.mdx,refresh.mdx,revalidatePath.mdx,revalidateTag.mdx,unauthorized.mdx,unstable_cache.mdx,unstable_noStore.mdx,unstable_rethrow.mdx,updateTag.mdx,use-link-status.mdx,use-params.mdx,use-pathname.mdx,use-report-web-vitals.mdx,use-router.mdx,use-search-params.mdx,use-selected-layout-segment.mdx,use-selected-layout-segments.mdx,userAgent.mdx}|01-app/03-api-reference/05-config/01-next-config-js:{adapterPath.mdx,allowedDevOrigins.mdx,appDir.mdx,assetPrefix.mdx,authInterrupts.mdx,basePath.mdx,cacheComponents.mdx,cacheHandlers.mdx,cacheLife.mdx,compress.mdx,crossOrigin.mdx,cssChunking.mdx,deploymentId.mdx,devIndicators.mdx,distDir.mdx,env.mdx,expireTime.mdx,exportPathMap.mdx,generateBuildId.mdx,generateEtags.mdx,headers.mdx,htmlLimitedBots.mdx,httpAgentOptions.mdx,images.mdx,incrementalCacheHandlerPath.mdx,inlineCss.mdx,logging.mdx,mdxRs.mdx,onDemandEntries.mdx,optimizePackageImports.mdx,output.mdx,pageExtensions.mdx,poweredByHeader.mdx,productionBrowserSourceMaps.mdx,proxyClientMaxBodySize.mdx,reactCompiler.mdx,reactMaxHeadersLength.mdx,reactStrictMode.mdx,redirects.mdx,rewrites.mdx,sassOptions.mdx,serverActions.mdx,serverComponentsHmrCache.mdx,serverExternalPackages.mdx,staleTimes.mdx,staticGeneration.mdx,taint.mdx,trailingSlash.mdx,transpilePackages.mdx,turbopack.mdx,turbopackFileSystemCache.mdx,turbopackIgnoreIssue.mdx,typedRoutes.mdx,typescript.mdx,urlImports.mdx,useLightningcss.mdx,viewTransition.mdx,webVitalsAttribution.mdx,webpack.mdx}|01-app/03-api-reference/05-config:{02-typescript.mdx,03-eslint.mdx}|01-app/03-api-reference/06-cli:{create-next-app.mdx,next.mdx}|02-pages/01-getting-started:{01-installation.mdx,02-project-structure.mdx,04-images.mdx,05-fonts.mdx,06-css.mdx,11-deploying.mdx}|02-pages/02-guides:{analytics.mdx,authentication.mdx,babel.mdx,ci-build-caching.mdx,content-security-policy.mdx,css-in-js.mdx,custom-server.mdx,debugging.mdx,draft-mode.mdx,environment-variables.mdx,forms.mdx,incremental-static-regeneration.mdx,instrumentation.mdx,internationalization.mdx,lazy-loading.mdx,mdx.mdx,multi-zones.mdx,open-telemetry.mdx,package-bundling.mdx,post-css.mdx,preview-mode.mdx,production-checklist.mdx,redirecting.mdx,sass.mdx,scripts.mdx,self-hosting.mdx,static-exports.mdx,tailwind-v3-css.mdx,third-party-libraries.mdx}|02-pages/02-guides/migrating:{app-router-migration.mdx,from-create-react-app.mdx,from-vite.mdx}|02-pages/02-guides/testing:{cypress.mdx,jest.mdx,playwright.mdx,vitest.mdx}|02-pages/02-guides/upgrading:{codemods.mdx,version-10.mdx,version-11.mdx,version-12.mdx,version-13.mdx,version-14.mdx,version-9.mdx}|02-pages/03-building-your-application/01-routing:{01-pages-and-layouts.mdx,02-dynamic-routes.mdx,03-linking-and-navigating.mdx,05-custom-app.mdx,06-custom-document.mdx,07-api-routes.mdx,08-custom-error.mdx}|02-pages/03-building-your-application/02-rendering:{01-server-side-rendering.mdx,02-static-site-generation.mdx,04-automatic-static-optimization.mdx,05-client-side-rendering.mdx}|02-pages/03-building-your-application/03-data-fetching:{01-get-static-props.mdx,02-get-static-paths.mdx,03-forms-and-mutations.mdx,03-get-server-side-props.mdx,05-client-side.mdx}|02-pages/03-building-your-application/06-configuring:{12-error-handling.mdx}|02-pages/04-api-reference:{06-edge.mdx,08-turbopack.mdx}|02-pages/04-api-reference/01-components:{font.mdx,form.mdx,head.mdx,image-legacy.mdx,image.mdx,link.mdx,script.mdx}|02-pages/04-api-reference/02-file-conventions:{instrumentation.mdx,proxy.mdx,public-folder.mdx,src-folder.mdx}|02-pages/04-api-reference/03-functions:{get-initial-props.mdx,get-server-side-props.mdx,get-static-paths.mdx,get-static-props.mdx,next-request.mdx,next-response.mdx,use-params.mdx,use-report-web-vitals.mdx,use-router.mdx,use-search-params.mdx,userAgent.mdx}|02-pages/04-api-reference/04-config/01-next-config-js:{adapterPath.mdx,allowedDevOrigins.mdx,assetPrefix.mdx,basePath.mdx,bundlePagesRouterDependencies.mdx,compress.mdx,crossOrigin.mdx,deploymentId.mdx,devIndicators.mdx,distDir.mdx,env.mdx,exportPathMap.mdx,generateBuildId.mdx,generateEtags.mdx,headers.mdx,httpAgentOptions.mdx,images.mdx,logging.mdx,onDemandEntries.mdx,optimizePackageImports.mdx,output.mdx,pageExtensions.mdx,poweredByHeader.mdx,productionBrowserSourceMaps.mdx,proxyClientMaxBodySize.mdx,reactStrictMode.mdx,redirects.mdx,rewrites.mdx,serverExternalPackages.mdx,trailingSlash.mdx,transpilePackages.mdx,turbopack.mdx,typescript.mdx,urlImports.mdx,useLightningcss.mdx,webVitalsAttribution.mdx,webpack.mdx}|02-pages/04-api-reference/04-config:{01-typescript.mdx,02-eslint.mdx}|02-pages/04-api-reference/05-cli:{create-next-app.mdx,next.mdx}|03-architecture:{accessibility.mdx,fast-refresh.mdx,nextjs-compiler.mdx,supported-browsers.mdx}|04-community:{01-contribution-guide.mdx,02-rspack.mdx}<!-- NEXT-AGENTS-MD-END -->
diff --git a/web/CLAUDE.md b/web/CLAUDE.md
index c92a44f7be..1d39c7336c 100644
--- a/web/CLAUDE.md
+++ b/web/CLAUDE.md
@@ -1,3 +1,8 @@
+# CLAUDE.md
+Claude Code should treat this file as the package entrypoint for `web/`.
-<!-- NEXT-AGENTS-MD-START -->[Next.js Docs Index]|root: ./.next-docs|STOP. What you remember about Next.js is WRONG for this project. Always search docs and read before any task.|If docs missing, run this command first: npx @next/codemod agents-md --output CLAUDE.md|01-app:{04-glossary.mdx}|01-app/01-getting-started:{01-installation.mdx,02-project-structure.mdx,03-layouts-and-pages.mdx,04-linking-and-navigating.mdx,05-server-and-client-components.mdx,06-fetching-data.mdx,07-mutating-data.mdx,08-caching.mdx,09-revalidating.mdx,10-error-handling.mdx,11-css.mdx,12-images.mdx,13-fonts.mdx,14-metadata-and-og-images.mdx,15-route-handlers.mdx,16-proxy.mdx,17-deploying.mdx,18-upgrading.mdx}|01-app/02-guides:{ai-agents.mdx,analytics.mdx,authentication.mdx,backend-for-frontend.mdx,caching-without-cache-components.mdx,ci-build-caching.mdx,content-security-policy.mdx,css-in-js.mdx,custom-server.mdx,data-security.mdx,debugging.mdx,draft-mode.mdx,environment-variables.mdx,forms.mdx,incremental-static-regeneration.mdx,instant-navigation.mdx,instrumentation.mdx,internationalization.mdx,json-ld.mdx,lazy-loading.mdx,local-development.mdx,mcp.mdx,mdx.mdx,memory-usage.mdx,migrating-to-cache-components.mdx,multi-tenant.mdx,multi-zones.mdx,open-telemetry.mdx,package-bundling.mdx,prefetching.mdx,preserving-ui-state.mdx,production-checklist.mdx,progressive-web-apps.mdx,public-static-pages.mdx,redirecting.mdx,sass.mdx,scripts.mdx,self-hosting.mdx,single-page-applications.mdx,static-exports.mdx,streaming.mdx,tailwind-v3-css.mdx,third-party-libraries.mdx,videos.mdx}|01-app/02-guides/migrating:{app-router-migration.mdx,from-create-react-app.mdx,from-vite.mdx}|01-app/02-guides/testing:{cypress.mdx,jest.mdx,playwright.mdx,vitest.mdx}|01-app/02-guides/upgrading:{codemods.mdx,version-14.mdx,version-15.mdx,version-16.mdx}|01-app/03-api-reference:{07-edge.mdx,08-turbopack.mdx}|01-app/03-api-reference/01-directives:{use-cache-private.mdx,use-cache-remote.mdx,use-cache.mdx,use-client.mdx,use-server.mdx}|01-app/03-api-reference/02-components:{font.mdx,form.mdx,image.mdx,link.mdx,script.mdx}|01-app/03-api-reference/03-file-conventions/01-metadata:{app-icons.mdx,manifest.mdx,opengraph-image.mdx,robots.mdx,sitemap.mdx}|01-app/03-api-reference/03-file-conventions/02-route-segment-config:{dynamicParams.mdx,instant.mdx,maxDuration.mdx,preferredRegion.mdx,runtime.mdx}|01-app/03-api-reference/03-file-conventions:{default.mdx,dynamic-routes.mdx,error.mdx,forbidden.mdx,instrumentation-client.mdx,instrumentation.mdx,intercepting-routes.mdx,layout.mdx,loading.mdx,mdx-components.mdx,not-found.mdx,page.mdx,parallel-routes.mdx,proxy.mdx,public-folder.mdx,route-groups.mdx,route.mdx,src-folder.mdx,template.mdx,unauthorized.mdx}|01-app/03-api-reference/04-functions:{after.mdx,cacheLife.mdx,cacheTag.mdx,catchError.mdx,connection.mdx,cookies.mdx,draft-mode.mdx,fetch.mdx,forbidden.mdx,generate-image-metadata.mdx,generate-metadata.mdx,generate-sitemaps.mdx,generate-static-params.mdx,generate-viewport.mdx,headers.mdx,image-response.mdx,next-request.mdx,next-response.mdx,not-found.mdx,permanentRedirect.mdx,redirect.mdx,refresh.mdx,revalidatePath.mdx,revalidateTag.mdx,unauthorized.mdx,unstable_cache.mdx,unstable_noStore.mdx,unstable_rethrow.mdx,updateTag.mdx,use-link-status.mdx,use-params.mdx,use-pathname.mdx,use-report-web-vitals.mdx,use-router.mdx,use-search-params.mdx,use-selected-layout-segment.mdx,use-selected-layout-segments.mdx,userAgent.mdx}|01-app/03-api-reference/05-config/01-next-config-js:{adapterPath.mdx,allowedDevOrigins.mdx,appDir.mdx,assetPrefix.mdx,authInterrupts.mdx,basePath.mdx,cacheComponents.mdx,cacheHandlers.mdx,cacheLife.mdx,compress.mdx,crossOrigin.mdx,cssChunking.mdx,deploymentId.mdx,devIndicators.mdx,distDir.mdx,env.mdx,expireTime.mdx,exportPathMap.mdx,generateBuildId.mdx,generateEtags.mdx,headers.mdx,htmlLimitedBots.mdx,httpAgentOptions.mdx,images.mdx,incrementalCacheHandlerPath.mdx,inlineCss.mdx,logging.mdx,mdxRs.mdx,onDemandEntries.mdx,optimizePackageImports.mdx,output.mdx,pageExtensions.mdx,poweredByHeader.mdx,productionBrowserSourceMaps.mdx,proxyClientMaxBodySize.mdx,reactCompiler.mdx,reactMaxHeadersLength.mdx,reactStrictMode.mdx,redirects.mdx,rewrites.mdx,sassOptions.mdx,serverActions.mdx,serverComponentsHmrCache.mdx,serverExternalPackages.mdx,staleTimes.mdx,staticGeneration.mdx,taint.mdx,trailingSlash.mdx,transpilePackages.mdx,turbopack.mdx,turbopackFileSystemCache.mdx,turbopackIgnoreIssue.mdx,typedRoutes.mdx,typescript.mdx,urlImports.mdx,useLightningcss.mdx,viewTransition.mdx,webVitalsAttribution.mdx,webpack.mdx}|01-app/03-api-reference/05-config:{02-typescript.mdx,03-eslint.mdx}|01-app/03-api-reference/06-cli:{create-next-app.mdx,next.mdx}|02-pages/01-getting-started:{01-installation.mdx,02-project-structure.mdx,04-images.mdx,05-fonts.mdx,06-css.mdx,11-deploying.mdx}|02-pages/02-guides:{analytics.mdx,authentication.mdx,babel.mdx,ci-build-caching.mdx,content-security-policy.mdx,css-in-js.mdx,custom-server.mdx,debugging.mdx,draft-mode.mdx,environment-variables.mdx,forms.mdx,incremental-static-regeneration.mdx,instrumentation.mdx,internationalization.mdx,lazy-loading.mdx,mdx.mdx,multi-zones.mdx,open-telemetry.mdx,package-bundling.mdx,post-css.mdx,preview-mode.mdx,production-checklist.mdx,redirecting.mdx,sass.mdx,scripts.mdx,self-hosting.mdx,static-exports.mdx,tailwind-v3-css.mdx,third-party-libraries.mdx}|02-pages/02-guides/migrating:{app-router-migration.mdx,from-create-react-app.mdx,from-vite.mdx}|02-pages/02-guides/testing:{cypress.mdx,jest.mdx,playwright.mdx,vitest.mdx}|02-pages/02-guides/upgrading:{codemods.mdx,version-10.mdx,version-11.mdx,version-12.mdx,version-13.mdx,version-14.mdx,version-9.mdx}|02-pages/03-building-your-application/01-routing:{01-pages-and-layouts.mdx,02-dynamic-routes.mdx,03-linking-and-navigating.mdx,05-custom-app.mdx,06-custom-document.mdx,07-api-routes.mdx,08-custom-error.mdx}|02-pages/03-building-your-application/02-rendering:{01-server-side-rendering.mdx,02-static-site-generation.mdx,04-automatic-static-optimization.mdx,05-client-side-rendering.mdx}|02-pages/03-building-your-application/03-data-fetching:{01-get-static-props.mdx,02-get-static-paths.mdx,03-forms-and-mutations.mdx,03-get-server-side-props.mdx,05-client-side.mdx}|02-pages/03-building-your-application/06-configuring:{12-error-handling.mdx}|02-pages/04-api-reference:{06-edge.mdx,08-turbopack.mdx}|02-pages/04-api-reference/01-components:{font.mdx,form.mdx,head.mdx,image-legacy.mdx,image.mdx,link.mdx,script.mdx}|02-pages/04-api-reference/02-file-conventions:{instrumentation.mdx,proxy.mdx,public-folder.mdx,src-folder.mdx}|02-pages/04-api-reference/03-functions:{get-initial-props.mdx,get-server-side-props.mdx,get-static-paths.mdx,get-static-props.mdx,next-request.mdx,next-response.mdx,use-params.mdx,use-report-web-vitals.mdx,use-router.mdx,use-search-params.mdx,userAgent.mdx}|02-pages/04-api-reference/04-config/01-next-config-js:{adapterPath.mdx,allowedDevOrigins.mdx,assetPrefix.mdx,basePath.mdx,bundlePagesRouterDependencies.mdx,compress.mdx,crossOrigin.mdx,deploymentId.mdx,devIndicators.mdx,distDir.mdx,env.mdx,exportPathMap.mdx,generateBuildId.mdx,generateEtags.mdx,headers.mdx,httpAgentOptions.mdx,images.mdx,logging.mdx,onDemandEntries.mdx,optimizePackageImports.mdx,output.mdx,pageExtensions.mdx,poweredByHeader.mdx,productionBrowserSourceMaps.mdx,proxyClientMaxBodySize.mdx,reactStrictMode.mdx,redirects.mdx,rewrites.mdx,serverExternalPackages.mdx,trailingSlash.mdx,transpilePackages.mdx,turbopack.mdx,typescript.mdx,urlImports.mdx,useLightningcss.mdx,webVitalsAttribution.mdx,webpack.mdx}|02-pages/04-api-reference/04-config:{01-typescript.mdx,02-eslint.mdx}|02-pages/04-api-reference/05-cli:{create-next-app.mdx,next.mdx}|03-architecture:{accessibility.mdx,fast-refresh.mdx,nextjs-compiler.mdx,supported-browsers.mdx}|04-community:{01-contribution-guide.mdx,02-rspack.mdx}<!-- NEXT-AGENTS-MD-END -->
+Start here:
+- Read @AGENTS.md for package-local guidance, shared package import rules, and
+ package-local skills.
+- Then read @../AGENTS.md for monorepo-level rules.
diff --git a/worker/AGENTS.md b/worker/AGENTS.md
index 6d25cebcbe..f2b21af813 100644
--- a/worker/AGENTS.md
+++ b/worker/AGENTS.md
@@ -28,6 +28,28 @@ Use root [AGENTS.md](../AGENTS.md) for monorepo-level rules.
- Background migrations: `src/backgroundMigrations/*`
- Tests: `src/__tests__/*`, `src/queues/__tests__/*`
+## Shared Package Imports
+
+- Prefer `@langfuse/shared/src/server` in worker runtime code for queue
+ helpers/contracts, repositories, logger/instrumentation, Redis/ClickHouse
+ helpers, auth helpers, and other shared backend services.
+- Use `@langfuse/shared` for cross-runtime types, schemas, domain contracts,
+ model-pricing helpers, and other frontend-safe utilities.
+- Use `@langfuse/shared/src/db` only when worker code or tests need direct
+ Prisma access.
+- Use narrower subpaths such as `@langfuse/shared/src/env` or
+ `@langfuse/shared/encryption` when you specifically need those focused
+ helpers instead of the broader barrels.
+- See `../packages/shared/AGENTS.md` for the full shared export map and what
+ each entrypoint contains.
+- For the higher-level platform topology across web, worker, Postgres,
+ ClickHouse, Redis, and S3, also read the architecture handbook:
+ [langfuse.com/handbook/product-engineering/architecture](https://langfuse.com/handbook/product-engineering/architecture)
+ with source markdown in
+ `../langfuse-docs/content/handbook/product-engineering/architecture.mdx`
+ (GitHub mirror:
+ [architecture.mdx](https://github.com/langfuse/langfuse-docs/blob/4188c1ba453240c90a763a8067ef442d68839323/content/handbook/product-engineering/architecture.mdx#L4)).
+
## Quick Commands
- Dev: `pnpm --filter worker run dev`