Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .claude/rules/coding-style.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,47 @@ console.log('Workbook created successfully');

Prefer placing the single authoritative log in the service layer; remove duplicate logs in route handlers that cover the same event.

## No Hard-Coded Values

Extract magic numbers and strings to named constants. Never embed literal values whose meaning is not self-evident from the type or immediate context.

```typescript
// Bad
if (grade >= 11) { ... }

const url = '/api/workbooks/submit';

// Good
const MIN_GRADE = 11;

if (grade >= MIN_GRADE) { ... }

const SUBMIT_URL = '/api/workbooks/submit';
```

Place constants at the top of the file, or in a dedicated `constants/` module when shared across files.

## Function Ordering

Within a file, order declarations as follows:

1. Exported functions and classes (public API first)
2. Internal helper functions (supporting the exports above)

Shared helper functions (used by two or more exports) should be grouped at the end of the file.

Comment thread
coderabbitai[bot] marked this conversation as resolved.
## Svelte 5: Prefer Official Docs Over Training Knowledge

When Svelte 5 behavior is unclear, fetch the official docs directly via WebFetch instead of relying on training knowledge.

URL pattern: `https://svelte.dev/docs/svelte/{section}`

Examples:

- `$effect` behavior → `https://svelte.dev/docs/svelte/$effect`
- Stores usage → `https://svelte.dev/docs/svelte/stores`
- Runes overview → `https://svelte.dev/docs/svelte/what-are-runes`

## Async Rollback: Capture State Before `await`

Capture `$state` values before the first `await` for safe rollback. A concurrent update can overwrite the variable while awaiting:
Expand Down
18 changes: 0 additions & 18 deletions .claude/rules/svelte-docs.md

This file was deleted.

6 changes: 6 additions & 0 deletions .claude/rules/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ paths:

Write all test titles in English. Use descriptive sentences that state the expected behavior (e.g., `'returns empty array when workbooks is empty'`). Japanese is only acceptable in inline comments or fixture strings that represent real user-facing content.

## Tests Ship with the Implementation

Tests must be included in the same commit as the implementation they cover. "Add tests later" is not acceptable — a feature or fix is not done until its tests pass.

If a task description does not mention tests, add them anyway for any non-trivial logic.

## Test Integrity

- Never delete, comment out, or weaken assertions (e.g. `toEqual` → `toBeDefined`) to make tests pass
Expand Down
Loading