refactor: extract shared markdown builders for rules generation strat…#74
refactor: extract shared markdown builders for rules generation strat…#74mkczarkowski wants to merge 2 commits intomasterfrom
Conversation
…egies Extract common scaffolding from Single and Multi file strategies into reusable builders module. This reduces code duplication and ensures consistent formatting across both strategies. Key changes: - Created markdown-builders module with shared utilities - Extracted project header, empty state, and library section rendering - Unified iteration logic over layer/stack/library structure - Simplified both strategies to use shared builders Benefits: - Guarantees consistent formatting across strategies - Reduces effort when adding new strategies - Single source of truth for markdown generation logic - Easier maintenance and testing 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
|
✅ All checks have passed successfully!
Coverage reports have been uploaded as artifacts. |
|
Claude finished @mkczarkowski's task —— View job Code Review Complete ✅Tasks
SummaryThis PR successfully extracts common markdown generation logic from Overall Assessment: Approve with Minor Suggestions ✅ The refactoring is well-executed and all CI checks pass. However, I've identified several areas for improvement regarding type safety, unused code, and clarity. Detailed Review✅ Strengths
|
|
✅ All checks have passed successfully!
Coverage reports have been uploaded as artifacts. |
Problem
The
SingleFileRulesStrategyandMultiFileRulesStrategyclasses contained significant code duplication for generating markdown content. Both strategies independently implemented:This duplication made the codebase harder to maintain and increased the risk of inconsistencies when making changes.
Solution
Extracted common markdown generation logic into a shared utility module
rulesMarkdownBuilders.tscontaining:Shared Functions
createProjectMarkdown()- Generates consistent project headerscreateEmptyStateMarkdown()- Creates empty state messagesgenerateLibraryContent()- Formats individual library rulesrenderLibrarySection()- Renders complete library sections with headersgenerateLibrarySections()- Builds all library sections organized by layer/stackPROJECT_FILE_CONFIG- Centralizes default file configurationChanges Made
SingleFileRulesStrategyto use shared utilities (removed ~40 lines)MultiFileRulesStrategyto use shared utilities (removed ~20 lines)Benefits
✅ Eliminates ~60 lines of duplicate code
✅ Ensures consistent formatting across all strategies
✅ Simplifies adding new strategies - just import and use shared functions
✅ Makes copy changes easier - update in one place, affects all strategies
✅ Improves maintainability - single source of truth for markdown generation
✅ Better testability - shared functions can be unit tested independently
Testing
All existing tests pass without modification, confirming this is a pure refactoring with no behavior changes.
npm run test ✅ npm run lint:check ✅🤖 Generated with Claude Code