feat: Add Claude Code rules output format support and set up CLI for additional format support in the future#6
Open
poiley wants to merge 1 commit into
Open
Conversation
This commit addresses the Claude Code rules output format issue by implementing format-aware messaging throughout the CLI and fixing Claude formatter bugs. Key changes: - Remove legacy _legacy_save_rules_with_format function and fallback mechanisms - Fix ClaudeFormatter _convert_mdc_to_claude_section method to properly return formatted content - Add _get_format_action_text() helper for format-specific user prompts - Replace hardcoded Cursor-centric messages with format-aware alternatives - Update all user-facing prompts to use appropriate format terminology - Fix f-string syntax error in CLI prompt formatting Technical details: - Enhanced FormatManager to handle multiple output formats cleanly - Improved error handling in formatter conversion methods - Maintained backward compatibility for existing Cursor format workflows - Added comprehensive formatter architecture with base classes and registry pattern Fixes empty CLAUDE.md generation bug and ensures shell output matches selected format. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Implements Claude Code output format support by building a complete formatter architecture to replace the existing hardcoded Cursor format generation. This enables multi-IDE compatibility and extensible format support.
Technical Changes
New Formatter Architecture (
rules_engine/formatters/)Base Classes:
BaseFormatter: Abstract base class defining formatter interface withconvert(),save(), andget_info()methodsFormatError: Custom exception class for formatter-specific errorsConcrete Implementations:
CursorFormatter: Refactored existing logic into formatter class, maintains.cursor/rules/*.mdcoutput with YAML frontmatterClaudeFormatter: New implementation generatingCLAUDE.mdwith structured markdown sectionsManagement Layer:
FormatManager: Registry pattern with formatter discovery, validation, and batch processingCLI Integration (
rules_engine/cli.py)Parameter Addition:
--output-format/-oclick option with choices:cursor,claude,all, comma-separated listscursorwhen not specifiedArchitecture Changes:
FormatManager.convert_and_save()_legacy_save_rules_with_format()function and fallback mechanisms_get_format_action_text()and_get_format_description()helpers for format-aware messagingFormat Specifications
Cursor Format (existing, now formalized):
File structure:
Claude Format (new):
Core Logic Changes (
rules_engine/analyzer.py)save_rules_with_format()to use new formatter architectureUsage