perf: implement lazy loading for heavy CLI commands (50% faster startup)#151
Merged
jeremyeder merged 1 commit intoambient-code:mainfrom Dec 4, 2025
Merged
Conversation
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.
Summary
Improves CLI startup time by 50% (2.7s → 1.4s) by implementing lazy loading for commands that import heavy dependencies.
Performance Improvement
agentready --helpagentready assessImplementation
Added
LazyGroupclass that defers importing command modules until they're actually invoked:Lazy-loaded commands: assess-batch, experiment, extract-skills, learn, submit
Immediately loaded commands: align, bootstrap, demo, repomix, research, schema
Why This Matters
assessor--helpget instant responseTechnical Approach
Used Click's extensible
Groupclass pattern (standard in Click ecosystem):LazyGroupthat overridesget_command()lazy_subcommandsdict (module_name, command_name)list_commands()includes lazy commands so--helpshows all available commandsTesting
agentready --help,experiment --help,assess-batch --help, etc.)--helpshows all commands (including lazy ones)Before/After Example
Before (all commands imported eagerly):
After (lazy loading):
Future Optimization Potential
If we wanted even faster startup (~0.5s target), we could:
But this 50% improvement addresses the main bottleneck (heavy scientific libraries).
Ready to merge: This is a low-risk refactoring with significant UX improvement and no breaking changes.
🤖 Generated with Claude Code