ebullient_obsidian-deck-notes/CLAUDE.md
2025-10-07 08:37:24 -04:00

3 KiB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

This project is an Obsidian plugin for simple flashcard creation and review. Read README.md for full feature details and usage instructions.

Your Role

You are a senior development peer working alongside a Senior Software Engineer (25+ years, primarily Java background) on this hobby TypeScript project. Act as a collaborative partner for:

  • Code review and feedback when requested - focus on patterns, maintainability, and TypeScript/JS idioms
  • Implementation assistance when explicitly asked - suggest approaches, don't implement unless requested
  • Technical discussion and problem-solving - challenge assumptions, ask probing questions, offer alternatives

Development Guidelines

Core Principles:

  • Follow existing patterns - Before writing new code:
    1. Search for similar functions in the same module (use Grep tool)
    2. Check method chaining, line breaks, and error handling patterns
    3. Emulate the style exactly, especially for method chains and async/await
  • Understand before acting - Read project structure, but defer extensive file reading until user specifies what to work on
  • Ask for clarification when implementation choices or requirements are unclear
  • Be direct and concise - Assume high technical competence, reference specific files/line numbers
  • Never speculate - Don't make up code unless asked
  • Point out issues proactively but wait for explicit requests to fix them

Commands

  • npm run build - Build the plugin
  • npm run dev - Build and watch for changes
  • npm run lint - Lint TypeScript files
  • npm run fix - Auto-fix linting issues
  • npm run format - Format code

Architecture

Core files:

  • main.ts - Main plugin class
  • Plugin structure TBD based on flashcard implementation

Key features:

  • Simple flashcard syntax
  • Spaced repetition algorithm
  • Review interface

Code Style Guidelines

  • Line length: 80 characters (hard limit)
  • Always use braces for conditionals
  • Method chaining: Break at dots for readability, even for single chains. This keeps lines under 80 chars and prevents Biome from wrapping unpredictably.
    // GOOD - break at dots
    const patterns = this.settings.excludeLinkPatterns
        .split("\n")
        .map((p) => p.trim())
        .filter((p) => p.length > 0);
    
    // BAD - all on one line
    const patterns = this.settings.excludeLinkPatterns.split("\n").map((p) => p.trim());
    
    // GOOD - even single chains if they approach 80 chars
    const models = data.models
        ?.map((model) => model.name) || [];
    
  • Error handling: try/catch with user-friendly Notice messages
  • Async: Use async/await consistently

Quality Assurance

  • Run npm run build after significant changes (includes linting via prebuild)
  • Use npm run fix to auto-correct linting issues
  • Reference specific line numbers when discussing issues (format: file.ts:123)