Open
Conversation
Replace 48 manual require_relative calls with Zeitwerk autoloader. This enforces one-class-per-file organization, enables lazy loading, and eliminates brittle load-order dependencies. Key changes: - Split multi-class files into individual files (~50 new, ~20 deleted) - Collapse content_blocks/, messages/, types/, hooks/ directories - Configure inflections for MCP, CLI, JSON, SDK, API acronyms - Convert query.rb to ClaudeAgent::Query module - Move class methods from logging.rb/v2_session.rb to entry point - Add include Message directly in each message/content block class
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.
What
Migrate from 48 manual
require_relativecalls to Zeitwerk autoloading, enforcing one-class-per-file organization across the gem.Why
Zeitwerk eliminates brittle load-order dependencies, enables lazy loading, and enforces consistent file-to-constant naming conventions. This makes the codebase easier to navigate and prevents the class of bugs where a missing or misordered require breaks loading.
How
zeitwerk ~> 2.7runtime dependencyloader.collapseforcontent_blocks/,messages/,types/,hooks/(classes stay inClaudeAgent::namespace)query.rbfrom module reopening toClaudeAgent::Querymodulelogging.rbandv2_session.rbinto the entry pointinclude Messagedirectly in each message/content block class (replaces iteration overMESSAGE_TYPES/CONTENT_BLOCK_TYPES)content_blocks.rb,messages.rb,types.rb,errors.rb,permissions.rb)require_relativefrom internal files (kept stdlibrequireforjson,securerandom,open3)Test plan
ClaudeAgent.loader.eager_loadsucceeds (24 message types, 8 content block types)