|
| 1 | +# CLAUDE.md - AI Assistant Instructions |
| 2 | + |
| 3 | +## Important Rules |
| 4 | + |
| 5 | +1. **Test Coverage**: Please run test/coverage before and after any work. Coverage needs to be 100% for a task to be complete. |
| 6 | + ```bash |
| 7 | + npm run test:coverage |
| 8 | + ``` |
| 9 | + |
| 10 | +2. **No Commits Without Permission**: Don't commit or push code unless I explicitly tell you to. |
| 11 | + |
| 12 | +3. **Code Quality Standards**: |
| 13 | + - Maintain 100% test coverage at all times |
| 14 | + - Follow existing code style and patterns |
| 15 | + - Use CommonJS modules (not ES6 modules) for compatibility |
| 16 | + - Keep the zero-dependency philosophy |
| 17 | + |
| 18 | +## Project Structure |
| 19 | + |
| 20 | +``` |
| 21 | +mdtail.dev/ |
| 22 | +├── lib/ |
| 23 | +│ ├── mdtail.js # Main application class |
| 24 | +│ ├── display.js # Terminal display logic |
| 25 | +│ ├── fileManager.js # File operations and watching |
| 26 | +│ └── errors.js # Custom error classes |
| 27 | +├── test/ |
| 28 | +│ ├── mdtail.test.js # Core unit tests |
| 29 | +│ ├── mdtail.integration.test.js # Integration tests |
| 30 | +│ ├── mdtail.edge.test.js # Edge cases |
| 31 | +│ ├── display.test.js # Display module tests |
| 32 | +│ ├── fileManager.test.js # File manager tests |
| 33 | +│ └── errors.test.js # Error classes tests |
| 34 | +├── index.js # CLI entry point |
| 35 | +├── index.d.ts # TypeScript definitions |
| 36 | +└── package.json |
| 37 | +
|
| 38 | +``` |
| 39 | + |
| 40 | +## Testing Commands |
| 41 | + |
| 42 | +```bash |
| 43 | +npm test # Run all tests |
| 44 | +npm run test:watch # Run tests in watch mode |
| 45 | +npm run test:coverage # Run tests with coverage report |
| 46 | +``` |
| 47 | + |
| 48 | +## Common Tasks |
| 49 | + |
| 50 | +### Adding New Features |
| 51 | +1. Run tests first to ensure 100% coverage: `npm run test:coverage` |
| 52 | +2. Implement the feature |
| 53 | +3. Add comprehensive tests for the new feature |
| 54 | +4. Run tests again to ensure 100% coverage is maintained |
| 55 | +5. Do NOT commit unless explicitly asked |
| 56 | + |
| 57 | +### Refactoring |
| 58 | +1. Run tests first to ensure 100% coverage |
| 59 | +2. Make refactoring changes |
| 60 | +3. Ensure all tests still pass |
| 61 | +4. Verify 100% coverage is maintained |
| 62 | +5. Do NOT commit unless explicitly asked |
| 63 | + |
| 64 | +### Bug Fixes |
| 65 | +1. Add a failing test that reproduces the bug |
| 66 | +2. Fix the bug |
| 67 | +3. Ensure the test now passes |
| 68 | +4. Verify 100% coverage is maintained |
| 69 | +5. Do NOT commit unless explicitly asked |
| 70 | + |
| 71 | +## Key Implementation Details |
| 72 | + |
| 73 | +- **File Watching**: Uses `fs.watchFile` with 100ms polling interval |
| 74 | +- **Terminal Features**: Graceful degradation for non-TTY environments |
| 75 | +- **Error Handling**: Custom error classes with helpful suggestions |
| 76 | +- **Display**: ANSI escape codes with fallbacks for limited terminals |
| 77 | +- **Navigation**: Arrow keys for multi-file tab switching |
| 78 | + |
| 79 | +## NPM Publishing |
| 80 | + |
| 81 | +The package is published as `mdtail` on npm. When preparing releases: |
| 82 | +1. Ensure all tests pass with 100% coverage |
| 83 | +2. Update version in package.json |
| 84 | +3. Test the package locally with `npm pack` |
| 85 | +4. Only publish after explicit approval |
0 commit comments