Guidelines for AI agents (Claude, Copilot, Cursor, etc.) working on this codebase.
ChordSheetJS is a JavaScript/TypeScript library for parsing and formatting chord sheets (ChordPro, Ultimate Guitar, chords-over-words formats).
- Node.js - Ensure Node.js is installed
- Yarn 4 - This project uses Yarn 4 via Corepack
corepack enable # If yarn doesn't work
- Install dependencies:
yarn install
- Build (generates parsers and compiles TypeScript):
yarn build
Always work test-driven:
- Write a failing test first - Before implementing any feature or fix
- Run the test to confirm it fails for the right reason
- Implement the minimal code to make the test pass
- Refactor if needed, keeping tests green
- Run full test suite before committing
| Command | When to use |
|---|---|
yarn test |
Before committing - runs lint + all tests |
yarn lint |
Quick check for code style issues |
yarn lint:fix |
Fix auto-fixable lint issues |
yarn build |
After changing .pegjs grammar files |
yarn build -f |
Force rebuild (regenerate all parsers) |
yarn build -r |
Build release files (for publishing) |
yarn release [major|minor|patch] |
Full release to npm (see below) |
- Starting work:
yarn install(if dependencies changed) - After modifying
.pegjsfiles:yarn build - Before committing:
yarn test - Lint errors: Try
yarn lint:fixfirst, then fix remaining manually
src/
├── parser/ # Parsers (ChordPro, UltimateGuitar, ChordsOverWords)
│ └── */peg_parser.ts # GENERATED - don't edit!
├── formatter/ # Output formatters
├── chord_sheet/ # Core classes (Song, Line, ChordLyricsPair, etc.)
└── chord/ # Chord parsing and manipulation
test/ # Tests mirror src/ structure
peg_parser.tsfiles are generated from.pegjsgrammars- Run
yarn buildto regenerate parsers after grammar changes
Enforced by ESLint:
- Max 120 characters per line
- Max 25 lines per function
- Max 12 statements per function
- Max cyclomatic complexity: 11
- Max nesting depth: 2
- Single quotes for strings
- Object curly spacing:
{ like, this }
- Create a fresh branch from
master - Work test-driven (write test → implement → refactor)
- Run
yarn testbefore committing - Create PR targeting
master
- Write clear, concise commit messages
- No AI attribution in commits (no Co-Authored-By lines)
- Keep PR descriptions short and focused
- Summary only, no test plan section needed
- Tests are in
test/directory, mirroringsrc/structure - Use existing test patterns as examples
- Test both happy path and edge cases
- For parser changes, test with actual chord sheet examples
yarn release [major|minor|patch]This command handles the full release process:
- Runs all checks (lint + tests)
- Builds all release files
- Bumps the version in
package.json - Commits the version bump
- Creates a git tag
- Pushes the commit and tag to origin
- Publishes to npm
- Editing
peg_parser.ts- These are generated! Edit the.pegjsfiles instead - Forgetting to build - After
.pegjschanges, runyarn build - Skipping tests - Always run
yarn testbefore committing