Add claude CLI aliases for quick model selection#212
Conversation
Adds cldo, clds, and cldk aliases for launching claude with opus, sonnet, and haiku models respectively, all with dangerously-skip-permissions flag. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
WalkthroughThe pull request adds three new zsh shell aliases to Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.zshrc:
- Around line 56-58: The aliases cldo, clds, and cldk won’t forward runtime
arguments because zsh aliases do textual substitution and don’t accept
positional parameters; replace each alias with a shell function (e.g., define
cldo(), clds(), cldk()) that invokes the claude command with the appropriate
--model value and forwards all invocation arguments using "$@"; update the
existing alias lines to function definitions that call claude
--dangerously-skip-permissions --model=opus/sonnet/haiku respectively and pass
"$@" so arguments are forwarded correctly.
| alias cldo="claude --dangerously-skip-permissions --model=opus $@" | ||
| alias clds="claude --dangerously-skip-permissions --model=sonnet $@" | ||
| alias cldk="claude --dangerously-skip-permissions --model=haiku $@" |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
zsh alias $@ argument forwarding vs function
💡 Result:
In zsh, an alias is just textual substitution of the first word of a command line; it does not receive positional parameters, so $@ inside an alias does not mean “the alias’s arguments” (it either expands when the alias is defined or is treated literally, depending on quoting) and won’t forward what you type after the alias name. [1], [2], [3]
What to use instead: a function
Use a function when you need argument forwarding (or any real logic):
mycmd() {
realcmd "$@"
}"$@" expands to the arguments passed to the function call. [2]
When an alias “seems” to forward args
This works because the shell appends the extra words after the alias expansion:
alias ll='ls -l'
# `ll /tmp` becomes `ls -l /tmp`But you still can’t inspect/rewrite/conditionally use those arguments from within an alias (no reliable $@ concept). [1]
If you tried something like this
alias ls='command -v lsd >/dev/null && lsd "$@" || ls "$@"'That fails for the reason above: aliases aren’t functions, so they don’t have $@; make it a function (and usually do the detection once, at startup, if possible). [3]
Sources:
[1] Zsh Guide: aliases don’t take arguments; use functions (zsh.sourceforge.io) (zsh.sourceforge.io)
[2] Ask Different: use a function + "$@" to pass arguments (apple.stackexchange.com) (apple.stackexchange.com)
[3] Reddit explanation: “Aliases aren’t functions, they don’t have $@” (reddit.com) (reddit.com)
Citations:
- 1: https://zsh.sourceforge.io/Guide/zshguide03.html?utm_source=openai
- 2: https://apple.stackexchange.com/questions/457982/zsh-alias-doesnt-always-take-arguments?utm_source=openai
- 3: https://www.reddit.com/r/linuxquestions/comments/1dbcl6m?utm_source=openai
Aliases won't forward invocation arguments; use functions instead.
These aliases attempt to forward arguments via $@, but in zsh, aliases perform only textual substitution and do not receive positional parameters. The $@ inside the alias text will not expand to the arguments passed when calling cldo, clds, or cldk.
Proposed fix
-alias cldo="claude --dangerously-skip-permissions --model=opus $@"
-alias clds="claude --dangerously-skip-permissions --model=sonnet $@"
-alias cldk="claude --dangerously-skip-permissions --model=haiku $@"
+cldo() { command claude --dangerously-skip-permissions --model=opus "$@"; }
+clds() { command claude --dangerously-skip-permissions --model=sonnet "$@"; }
+cldk() { command claude --dangerously-skip-permissions --model=haiku "$@"; }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| alias cldo="claude --dangerously-skip-permissions --model=opus $@" | |
| alias clds="claude --dangerously-skip-permissions --model=sonnet $@" | |
| alias cldk="claude --dangerously-skip-permissions --model=haiku $@" | |
| cldo() { command claude --dangerously-skip-permissions --model=opus "$@"; } | |
| clds() { command claude --dangerously-skip-permissions --model=sonnet "$@"; } | |
| cldk() { command claude --dangerously-skip-permissions --model=haiku "$@"; } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.zshrc around lines 56 - 58, The aliases cldo, clds, and cldk won’t forward
runtime arguments because zsh aliases do textual substitution and don’t accept
positional parameters; replace each alias with a shell function (e.g., define
cldo(), clds(), cldk()) that invokes the claude command with the appropriate
--model value and forwards all invocation arguments using "$@"; update the
existing alias lines to function definitions that call claude
--dangerously-skip-permissions --model=opus/sonnet/haiku respectively and pass
"$@" so arguments are forwarded correctly.
Summary
cldo,clds,cldkshell aliases for launching Claude Code with opus, sonnet, and haiku models--dangerously-skip-permissionsfor unattended usageTest plan
.zshrcand verifycldo,clds,cldkaliases are available🤖 Generated with Claude Code
Summary by CodeRabbit
Chores