Skip to content

Commit f7f18e5

Browse files
committed
fix(claude-code): address PR review feedback for yoloAlias
Make alias appending idempotent with grep guard, add security warning to docs, and strengthen test assertions to verify full command string.
1 parent 08059ca commit f7f18e5

3 files changed

Lines changed: 23 additions & 5 deletions

File tree

src/claude-code/NOTES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ The channel chosen at install time becomes the default for auto-updates.
1717

1818
When `yoloAlias` is set to `true`, a `yolo` shell alias is created that expands to `claude --allow-dangerously-skip-permissions`. The alias is configured for bash, zsh, and fish.
1919

20+
> **Warning:** `--allow-dangerously-skip-permissions` disables Claude Code's normal permission checks and confirmation prompts for potentially sensitive actions. This meaningfully reduces safety and may allow unintended or unsafe changes, so only enable `yoloAlias` if you understand and accept the security implications.
21+
>
22+
> Creating this alias may also override an existing `yolo` alias in your shell configuration.
23+
2024
## Auto-Updates
2125

2226
The native binary automatically updates in the background. Update checks are performed on startup and periodically while running. To disable auto-updates, set the `DISABLE_AUTOUPDATER=1` environment variable.

src/claude-code/install.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,25 @@ if [ "${YOLOALIAS:-false}" = "true" ]; then
5959
ALIAS_CMD='alias yolo="claude --allow-dangerously-skip-permissions"'
6060
TARGET_HOME="${INSTALL_HOME}"
6161

62+
add_shell_alias_if_missing() {
63+
local rc_file="$1"
64+
local alias_name="$2"
65+
local alias_cmd="$3"
66+
67+
if [ -f "$rc_file" ] && grep -Eq "^[[:space:]]*alias[[:space:]]+${alias_name}=" "$rc_file"; then
68+
echo "Skipping $rc_file: alias '$alias_name' already exists."
69+
return 0
70+
fi
71+
72+
touch "$rc_file"
73+
printf '%s\n' "$alias_cmd" >> "$rc_file"
74+
}
75+
6276
# bash
63-
echo "$ALIAS_CMD" >> "$TARGET_HOME/.bashrc"
77+
add_shell_alias_if_missing "$TARGET_HOME/.bashrc" "yolo" "$ALIAS_CMD"
6478

6579
# zsh
66-
echo "$ALIAS_CMD" >> "$TARGET_HOME/.zshrc"
80+
add_shell_alias_if_missing "$TARGET_HOME/.zshrc" "yolo" "$ALIAS_CMD"
6781

6882
# fish — create a function file (idiomatic for fish)
6983
FISH_FUNC_DIR="$TARGET_HOME/.config/fish/functions"

test/claude-code/claude_code_yolo_alias.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ source dev-container-features-test-lib
1010

1111
# Feature-specific tests
1212
check "claude command available" which claude
13-
check "yolo alias in bashrc" bash -c "grep -q 'alias yolo=' ~/.bashrc"
14-
check "yolo alias in zshrc" bash -c "grep -q 'alias yolo=' ~/.zshrc"
15-
check "fish yolo function exists" bash -c "test -f ~/.config/fish/functions/yolo.fish"
13+
check "yolo alias in bashrc" bash -c "grep -Fq 'claude --allow-dangerously-skip-permissions' ~/.bashrc"
14+
check "yolo alias in zshrc" bash -c "grep -Fq 'claude --allow-dangerously-skip-permissions' ~/.zshrc"
15+
check "fish yolo function body" bash -c "test -f ~/.config/fish/functions/yolo.fish && grep -Fq 'claude --allow-dangerously-skip-permissions' ~/.config/fish/functions/yolo.fish"
1616
check "yolo resolves in bash" bash -ic "type yolo"
1717

1818
# Report results

0 commit comments

Comments
 (0)