05-spec-pre-commit-cspell.md

Introduction/Overview

This specification adds a pre-commit hook for cspell (Code Spell Checker) to enforce spelling consistency across markdown documentation files in the repository. The hook will check all markdown files during commits, fail on spelling errors, and provide suggestions for corrections while requiring manual dictionary updates for project-specific terms. This ensures documentation quality and consistency while maintaining developer control over technical terminology.

Goals

User Stories

As a documentation maintainer, I want markdown files to be spell-checked automatically so that typos and spelling errors are caught before they reach the repository.

As a developer, I want clear feedback on spelling errors with suggestions so that I can quickly fix documentation issues without guessing correct spellings.

As a project maintainer, I want project-specific terms (like "Liatrio", "slash-man", "SDD") to be recognized as valid words so that technical terminology doesn't trigger false positives.

As a contributor, I want the spell checker to run consistently across all commits so that documentation quality standards are maintained automatically.

Demoable Units of Work

[Unit 1]: cspell Pre-commit Hook Integration

Purpose: Add cspell hook to the existing pre-commit configuration to check markdown files Demo Criteria: Running pre-commit run cspell --all-files successfully checks all markdown files and reports spelling errors (if any exist) Proof Artifacts: Updated .pre-commit-config.yaml with cspell hook, successful hook execution output, test: verify hook runs on commit attempt

[Unit 2]: cspell Configuration File Creation

Purpose: Create .cspell.json configuration file with project-specific dictionary and markdown file patterns Demo Criteria:

[Unit 3]: Pre-commit Hook Failure Behavior

Purpose: Verify that commits fail when spelling errors are detected in markdown files Demo Criteria:

[Unit 4]: Dictionary Management Workflow

Purpose: Demonstrate manual dictionary update process for adding project-specific terms Demo Criteria:

Functional Requirements

  1. The system shall check all markdown files (.md extension) during pre-commit hook execution, excluding CHANGELOG.md
  2. The system shall use a shared .cspell.json configuration file located at the repository root
  3. The system shall fail the commit when spelling errors are detected in markdown files
  4. The system shall provide spelling suggestions in error messages when misspellings are found
  5. The system shall recognize project-specific terms defined in the .cspell.json dictionary
  6. The system shall run on all files in the commit (not just changed files) to ensure consistency
  7. The system shall integrate with the existing pre-commit hook framework without breaking other hooks
  8. The system shall allow manual updates to the dictionary file for adding new project-specific terms
  9. The system shall exclude common false-positive patterns (code blocks, URLs, file paths) from spell checking
  10. The system shall provide clear error output indicating which files contain spelling errors and which words are misspelled
  11. The system shall use standard English (en_US) dictionary and proper capitalization for technical terms

Non-Goals (Out of Scope)

  1. Spell checking code files - This feature only checks markdown documentation files, not Python code, comments, or docstrings
  2. Automatic dictionary updates - Dictionary updates must be manual; the system will not auto-add words to the dictionary
  3. Spell checking during CI/CD - This is a pre-commit hook only; CI/CD spell checking is out of scope
  4. Integration with IDE spell checkers - IDE-specific spell checking configuration is not included
  5. Multi-language support - Only English spell checking is supported
  6. Auto-fixing spelling errors - The hook reports errors but does not automatically fix them
  7. Spell checking of generated files - Only source markdown files are checked, not generated documentation
  8. Spell checking CHANGELOG.md - CHANGELOG.md is excluded from spell checking as it may contain inconsistent formatting and auto-generated content

Design Considerations

No specific design requirements identified. This is a command-line tool integration with no UI components.

Repository Standards

Technical Considerations

Success Metrics

  1. Hook Integration: Pre-commit hook successfully runs cspell on all markdown files during commit attempts
  2. Error Detection: Spelling errors in markdown files cause commits to fail with clear error messages
  3. False Positive Reduction: Initial dictionary includes sufficient project-specific terms to minimize false positives (target: <5% false positive rate on existing markdown files)
  4. Developer Experience: Developers can successfully add new terms to dictionary and commit changes
  5. Documentation Quality: All existing markdown files pass spell checking after dictionary configuration

Open Questions

No open questions at this time.