diff --git a/docs/fish-config.index b/docs/fish-config.index index 9e7106d..8989ab6 100644 --- a/docs/fish-config.index +++ b/docs/fish-config.index @@ -130,6 +130,7 @@ logs=### logs smart-exit=### smart_exit ai=## 5.12 AI and Developer Tools antigravity=### antigravity +claude-cli=### claude claude=### claude-resume claude-docs=### claude-docs claude-pr=### claude-pr diff --git a/docs/fish-config.md b/docs/fish-config.md index 2041425..68dec9d 100644 --- a/docs/fish-config.md +++ b/docs/fish-config.md @@ -1106,6 +1106,20 @@ Add -i (interactive confirmation) to destructive commands: file in the current directory, or opens an interactive fzf picker if no session file is found. +### claude + + Synopsis: claude [args...] + Wrapper for the claude CLI. Before launching, checks the current + directory and the git project root for CLAUDE.md; when it is absent but + AGENTS.md is present, creates a relative symlink CLAUDE.md -> AGENTS.md + so Claude Code picks up shared agent instructions without duplicating + the file. All arguments are forwarded verbatim. Command shadow (C1): + when __fish_config_op_aliases (or the master) is disabled, the call is + passed through to the real claude binary unchanged. + + claude + claude --resume + ### claude-resume Synopsis: claude-resume @@ -1459,7 +1473,8 @@ but a category with an explicit truthy value remains enabled regardless. ping->prettyping, ssh->kitten, du->duf/dust, mkdir/bash wrappers, history timestamps, grep/cp/mv/wget - flag injection, help intercept + flag injection, help intercept, claude + AGENTS.md auto-link __fish_config_op_autoexec Startup side-effects: Fisher bootstrap, theme apply, paru/yay wrapper generation, auto venv @@ -1545,6 +1560,7 @@ all of these commands. grep/fgrep/egrep forced --color=auto system grep variants dir / vdir forced --color=auto system dir / vdir help config intercepts "help config" → config-help fish builtin help + claude auto-links AGENTS.md as CLAUDE.md before launch command claude When C1 is disabled, `rm` uses bare `command rm` with no wrapper — files are permanently deleted, not trashed. There is no intermediate safety net. diff --git a/functions/claude.fish b/functions/claude.fish new file mode 100644 index 0000000..cb05f41 --- /dev/null +++ b/functions/claude.fish @@ -0,0 +1,64 @@ +# Copyright (C) 2026 Rootiest +# SPDX-License-Identifier: AGPL-3.0-or-later + +# SYNOPSIS +# claude [ARGS...] +# +# DESCRIPTION +# Wrapper for the claude CLI that ensures CLAUDE.md exists before launch. +# Both the current directory and the git project root are checked. When +# CLAUDE.md is absent but AGENTS.md is present in a checked directory, a +# relative symlink CLAUDE.md -> AGENTS.md is created automatically so that +# Claude Code picks up shared agent instructions without duplicating the +# file. All arguments are forwarded verbatim to the real claude binary. +# +# Opinionated component (C1): when disabled via __fish_config_op_aliases +# (or the __fish_config_opinionated master), the command is passed through +# to the real claude binary unchanged. +# +# ARGUMENTS +# ARGS Any arguments forwarded verbatim to the underlying claude binary +# +# RETURNS +# Exit status of the underlying claude binary +# +# EXAMPLE +# claude +# claude --resume +# claude "Explain the recent changes" +function claude --wraps=claude --description 'claude wrapper: auto-links AGENTS.md as CLAUDE.md' + if not __fish_config_op_enabled __fish_config_op_aliases + command claude $argv + return $status + end + + set -l c_ok (set_color green) + set -l c_reset (set_color normal) + + # Build the list of directories to inspect: cwd always, git root when different. + set -l check_dirs (pwd) + set -l git_root (git rev-parse --show-toplevel 2>/dev/null) + if test -n "$git_root" -a "$git_root" != (pwd) + set check_dirs $check_dirs $git_root + end + + # Anchor for relative display: git root when available, otherwise cwd. + set -l anchor $git_root + test -z "$anchor" && set anchor (pwd) + + for dir in $check_dirs + if not test -e "$dir/CLAUDE.md" + if test -f "$dir/AGENTS.md" + ln -s AGENTS.md "$dir/CLAUDE.md" + set -l prefix "" + if test "$dir" != "$anchor" + set prefix (string replace "$anchor/" "" "$dir")/ + end + set -l msg (string join "" "→ Linked " $prefix "CLAUDE.md → " $prefix "AGENTS.md") + echo $c_ok$msg$c_reset >&2 + end + end + end + + command claude $argv +end