-
Notifications
You must be signed in to change notification settings - Fork 556
feat: enhance claude init with thinking mode, env vars, and npm path fix #772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: enhance claude init with thinking mode, env vars, and npm path fix #772
Conversation
Adds CLI flags to configure MAX_THINKING_TOKENS, alwaysThinkingEnabled, and default model when running 'humanlayer claude init'. Defaults to opus model with 32000 max thinking tokens and thinking mode enabled. - Add --model, --always-thinking, --max-thinking-tokens flags - Implement settings.json configuration with user preferences - Add 22 comprehensive e2e tests - Update gitignore for local settings Addresses ENG-2321
Set CLAUDE_BASH_MAINTAIN_WORKING_DIR=1 in the generated settings.json to maintain working directory context across bash commands in Claude Code sessions. This addresses the requirement from ENG-2321 to ensure proper bash session handling.
Fix path resolution bug where 'humanlayer claude init' was looking for /.claude instead of ./.claude when installed via npm. The command now checks multiple possible locations: - node_modules/humanlayer/.claude (npm install) - repo_root/.claude (development) Also improves error messages to show all searched paths when the .claude directory cannot be found. Addresses feedback from ENG-2321 where users had to manually copy the commands directory because init was failing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Caution
Changes requested ❌
Reviewed everything up to 309fdd7 in 1 minute and 44 seconds. Click for details.
- Reviewed
386lines of code in4files - Skipped
0files when reviewing. - Skipped posting
1draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. hlyr/src/commands/claude/init.ts:55
- Draft comment:
Multiple calls to process.exit are used for error handling and cancellation. Consider refactoring to throw errors instead of directly exiting. This can improve testability and allow for centralized error handling. - Reason this comment was not posted:
Comment was on unchanged code.
Workflow ID: wflow_SxKJJiOJ1frxpyqL
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
| .option('--always-thinking', 'Enable always-on thinking mode (default: true)') | ||
| .option('--no-always-thinking', 'Disable always-on thinking mode') | ||
| .option('--max-thinking-tokens <number>', 'Maximum thinking tokens (default: 32000)', value => | ||
| parseInt(value, 10), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider validating the parsed value for --max-thinking-tokens. Using parseInt without a check might allow NaN values to slip through. A check ensuring the value is numeric (and meets the minimum) would be beneficial.
| settings.alwaysThinkingEnabled = alwaysThinking | ||
| } | ||
| if (maxThinkingTokens !== undefined) { | ||
| if (!settings.env) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant settings.env initialization: the code checks and assigns settings.env before setting MAX_THINKING_TOKENS and again before setting CLAUDE_BASH_MAINTAIN_WORKING_DIR. Consolidate these checks into one initialization for clarity.
What problem(s) was I solving?
The
humanlayer claude initcommand had several issues that needed addressing (ENG-2321):CLAUDE_BASH_MAINTAIN_WORKING_DIRfor proper bash session handling/.claudeinstead of proper locationWhat user-facing changes did I ship?
New CLI Flags
Added three new CLI flags to
humanlayer claude init:--model <model>- Choose default model: haiku, sonnet, or opus (default: opus)--always-thinking/--no-always-thinking- Enable/disable thinking mode (default: enabled)--max-thinking-tokens <number>- Set maximum thinking tokens (default: 32000)Environment Configuration
The generated
.claude/settings.jsonnow includes:alwaysThinkingEnabled: true(configurable)env.MAX_THINKING_TOKENS: "32000"(configurable)env.CLAUDE_BASH_MAINTAIN_WORKING_DIR: "1"(always set)model: "opus"(configurable)Bug Fixes
.claudedirectory.claudedirectory cannot be foundHow I implemented it
Extended CLI interface (hlyr/src/commands/claude.ts):
Updated init command logic (hlyr/src/commands/claude/init.ts):
ModelTypetype and extendedInitOptionsinterface--allmodeCLAUDE_BASH_MAINTAIN_WORKING_DIR=1to environment variablesnode_modules/humanlayer/.claude(npm install).claude(development)Comprehensive test coverage (hlyr/tests/claudeInit.e2e.test.ts):
CLAUDE_BASH_MAINTAIN_WORKING_DIRis setHow to verify it
Test npm installation fix
Test configuration flags
Verify environment variables
Automated Testing
Description for the changelog
--model,--always-thinking, and--max-thinking-tokensflags tohumanlayer claude initfor configuring Claude Code thinking mode settingsclaude initfrom working when installed via npmCLAUDE_BASH_MAINTAIN_WORKING_DIRenvironment variable to maintain working directory across bash commands.claudedirectory cannot be foundImportant
Enhances
claude initwith new CLI flags for model and thinking mode, fixes path resolution, and updates environment configuration with comprehensive tests.--model,--always-thinking, and--max-thinking-tokensflags toclaude initinclaude.tsfor model selection and thinking mode configuration.init.tsto correctly locate.claudedirectory for npm installations..claude/settings.jsonto includealwaysThinkingEnabled,MAX_THINKING_TOKENS, andCLAUDE_BASH_MAINTAIN_WORKING_DIR.claudeInitCommandininit.tsto handle new flags and update settings.json accordingly.claudeInit.e2e.test.tsfor new CLI flags and path resolution.This description was created by
for 309fdd7. You can customize this summary. It will automatically update as commits are pushed.