Skip to content

Improve README configuration documentation and husky hooks. - #2

Merged
stevekrenzel merged 1 commit into
mainfrom
readme_update
Oct 28, 2025
Merged

Improve README configuration documentation and husky hooks.#2
stevekrenzel merged 1 commit into
mainfrom
readme_update

Conversation

@stevekrenzel

Copy link
Copy Markdown
Contributor

Problem:
The pre-commit hook was causing unintended behavior by auto-fixing and staging ALL modified files in the repository, not just the files the developer intended to commit. This happened because:

  1. The hook ran npm run lint which executed eslint --fix and prettier --write on the entire codebase
  2. After auto-fixing, it ran git add -u to re-stage all modified files
  3. This meant a commit of one file (e.g., README) would inadvertently include auto-fixed changes from completely unrelated files

This violated the principle of atomic commits and made it impossible to commit a subset of changes while keeping other work-in-progress changes unstaged.

Additionally, the README's configuration section was minimal, listing only environment variable names without explaining what each does or when to use them.

Solution:

  1. Installed lint-staged package to lint only staged files
  2. Updated pre-commit hook to use lint-staged instead of global linting
  3. Removed git add -u command that was re-staging all modified files
  4. Updated pre-commit npm script to remove linting (now handled by lint-staged)
  5. Enhanced README configuration section with detailed explanations

Implementation Details:

Pre-commit Hook Changes:

  • lint-staged now runs first, applying ESLint and Prettier only to staged .ts and .tsx files
  • Auto-fixed files are automatically re-staged by lint-staged
  • Full test suite, typecheck, and build still run on entire codebase for safety
  • This ensures code quality while preserving developer intent about what to commit

Configuration in package.json:

"lint-staged": {
  "*.{ts,tsx}": [
    "eslint --fix",
    "prettier --write"
  ]
}

README Improvements:

  • Added "Configuration Options" subsection with detailed descriptions
  • Each option now includes: name, purpose, default value, and usage guidance
  • Updated default model from llama-3.1-70b-versatile to openai/gpt-oss-120b
  • Clarified relationship between env vars and constructor overrides
  • Removed redundant bullet list from "Config" section

Edge Cases:

  • Unstaged files remain untouched even if they have linting issues
  • Developers can now commit partial changes while keeping WIP changes unstaged
  • If linting fails on staged files, the commit is blocked (as intended)
  • Integration with Husky remains intact

Why This Matters:
Atomic commits are essential for:

  • Clear git history and easier code review
  • Ability to cherry-pick or revert specific changes
  • Separating refactoring from feature work
  • Following git best practices

Better documentation reduces onboarding friction and helps users tune the library for their specific use case.

🤖 Generated with Claude Code

…nly lint staged files

**Problem:**
The pre-commit hook was causing unintended behavior by auto-fixing and staging
ALL modified files in the repository, not just the files the developer intended
to commit. This happened because:

1. The hook ran `npm run lint` which executed `eslint --fix` and
   `prettier --write` on the entire codebase
2. After auto-fixing, it ran `git add -u` to re-stage all modified files
3. This meant a commit of one file (e.g., README) would inadvertently include
   auto-fixed changes from completely unrelated files

This violated the principle of atomic commits and made it impossible to commit
a subset of changes while keeping other work-in-progress changes unstaged.

Additionally, the README's configuration section was minimal, listing only
environment variable names without explaining what each does or when to use
them.

**Solution:**
1. Installed `lint-staged` package to lint only staged files
2. Updated pre-commit hook to use `lint-staged` instead of global linting
3. Removed `git add -u` command that was re-staging all modified files
4. Updated `pre-commit` npm script to remove linting (now handled by lint-staged)
5. Enhanced README configuration section with detailed explanations

**Implementation Details:**

Pre-commit Hook Changes:
- `lint-staged` now runs first, applying ESLint and Prettier only to staged
  `.ts` and `.tsx` files
- Auto-fixed files are automatically re-staged by `lint-staged`
- Full test suite, typecheck, and build still run on entire codebase for safety
- This ensures code quality while preserving developer intent about what to commit

Configuration in package.json:
```json
"lint-staged": {
  "*.{ts,tsx}": [
    "eslint --fix",
    "prettier --write"
  ]
}
```

README Improvements:
- Added "Configuration Options" subsection with detailed descriptions
- Each option now includes: name, purpose, default value, and usage guidance
- Updated default model from llama-3.1-70b-versatile to openai/gpt-oss-120b
- Clarified relationship between env vars and constructor overrides
- Removed redundant bullet list from "Config" section

**Edge Cases:**
- Unstaged files remain untouched even if they have linting issues
- Developers can now commit partial changes while keeping WIP changes unstaged
- If linting fails on staged files, the commit is blocked (as intended)
- Integration with Husky remains intact

**Why This Matters:**
Atomic commits are essential for:
- Clear git history and easier code review
- Ability to cherry-pick or revert specific changes
- Separating refactoring from feature work
- Following git best practices

Better documentation reduces onboarding friction and helps users tune the
library for their specific use case.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@claude

claude Bot commented Oct 28, 2025

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

@stevekrenzel
stevekrenzel merged commit 2422954 into main Oct 28, 2025
3 of 4 checks passed
@stevekrenzel
stevekrenzel deleted the readme_update branch October 28, 2025 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant