Add shared agent instructions and tmux titling hook
This commit is contained in:
21
dotfiles/agents/AGENTS.md
Normal file
21
dotfiles/agents/AGENTS.md
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# Agentic Session Preferences
|
||||||
|
|
||||||
|
## Tmux session titling
|
||||||
|
- If the TMUX environment variable is set, treat this chat as the controller for the current tmux session.
|
||||||
|
- Maintain a session/window/pane title that updates when the task focus changes substantially.
|
||||||
|
- Prefer automatic titling: infer a concise <task> from the current user request and context without asking.
|
||||||
|
- Title format: "<project> - <task>".
|
||||||
|
- <project> is the basename of the current project directory.
|
||||||
|
- Prefer git repo root basename if available; otherwise use basename of the current working directory.
|
||||||
|
- <task> is a short, user-friendly description of what we are doing.
|
||||||
|
- Ask for a short descriptive <task> only when the task is ambiguous or you are not confident in an inferred title.
|
||||||
|
- When the task changes substantially, update the <task> automatically if clear; otherwise ask for an updated <task>.
|
||||||
|
- When a title is provided or updated, immediately run this one-liner:
|
||||||
|
|
||||||
|
tmux rename-session '<project> - <task>' \; rename-window '<project> - <task>' \; select-pane -T '<project> - <task>'
|
||||||
|
|
||||||
|
- Assume you are inside tmux, so do not use -t unless the user asks to target a specific session.
|
||||||
|
- For Claude Code sessions, a UserPromptSubmit hook will also update titles automatically based on the latest prompt.
|
||||||
|
|
||||||
|
## Pane usage
|
||||||
|
- Do not create extra panes or windows unless the user asks.
|
||||||
70
dotfiles/agents/hooks/tmux-title.sh
Executable file
70
dotfiles/agents/hooks/tmux-title.sh
Executable file
@@ -0,0 +1,70 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
if [[ -z "${TMUX:-}" ]]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
input=$(cat)
|
||||||
|
|
||||||
|
read -r cwd prompt <<'PY' < <(python3 - <<'PY'
|
||||||
|
import json, os, sys
|
||||||
|
try:
|
||||||
|
data = json.load(sys.stdin)
|
||||||
|
except Exception:
|
||||||
|
data = {}
|
||||||
|
|
||||||
|
cwd = data.get("cwd") or os.getcwd()
|
||||||
|
prompt = (data.get("prompt") or "").strip()
|
||||||
|
print(cwd)
|
||||||
|
print(prompt)
|
||||||
|
PY
|
||||||
|
)
|
||||||
|
|
||||||
|
if [[ -z "${cwd}" ]]; then
|
||||||
|
cwd="$PWD"
|
||||||
|
fi
|
||||||
|
|
||||||
|
project_root=$(git -C "$cwd" rev-parse --show-toplevel 2>/dev/null || true)
|
||||||
|
if [[ -n "$project_root" ]]; then
|
||||||
|
project=$(basename "$project_root")
|
||||||
|
else
|
||||||
|
project=$(basename "$cwd")
|
||||||
|
fi
|
||||||
|
|
||||||
|
prompt_first_line=$(printf '%s' "$prompt" | head -n 1 | tr '\n' ' ' | sed -e 's/[[:space:]]\+/ /g' -e 's/^ *//; s/ *$//')
|
||||||
|
|
||||||
|
lower=$(printf '%s' "$prompt_first_line" | tr '[:upper:]' '[:lower:]')
|
||||||
|
case "$lower" in
|
||||||
|
""|"ok"|"okay"|"thanks"|"thx"|"cool"|"yep"|"yes"|"no"|"sure"|"done"|"k")
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
task="$prompt_first_line"
|
||||||
|
if [[ -z "$task" ]]; then
|
||||||
|
task="work"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Trim to a reasonable length for tmux status bars.
|
||||||
|
if [[ ${#task} -gt 60 ]]; then
|
||||||
|
task="${task:0:57}..."
|
||||||
|
fi
|
||||||
|
|
||||||
|
title="$project - $task"
|
||||||
|
|
||||||
|
state_dir="${HOME}/.agents/state"
|
||||||
|
state_file="$state_dir/tmux-title"
|
||||||
|
mkdir -p "$state_dir"
|
||||||
|
|
||||||
|
if [[ -f "$state_file" ]]; then
|
||||||
|
last_title=$(cat "$state_file" 2>/dev/null || true)
|
||||||
|
if [[ "$last_title" == "$title" ]]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf '%s' "$title" > "$state_file"
|
||||||
|
|
||||||
|
# Update session, window, and pane titles.
|
||||||
|
tmux rename-session "$title" \; rename-window "$title" \; select-pane -T "$title"
|
||||||
1
dotfiles/claude/CLAUDE.md
Symbolic link
1
dotfiles/claude/CLAUDE.md
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../agents/AGENTS.md
|
||||||
18
dotfiles/claude/settings.json
Normal file
18
dotfiles/claude/settings.json
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"enabledPlugins": {
|
||||||
|
"superpowers@superpowers-marketplace": true,
|
||||||
|
"agent-browser@agent-browser": true
|
||||||
|
},
|
||||||
|
"hooks": {
|
||||||
|
"UserPromptSubmit": [
|
||||||
|
{
|
||||||
|
"hooks": [
|
||||||
|
{
|
||||||
|
"type": "command",
|
||||||
|
"command": "~/.agents/hooks/tmux-title.sh"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
1
dotfiles/codex/AGENTS.md
Symbolic link
1
dotfiles/codex/AGENTS.md
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../agents/AGENTS.md
|
||||||
Reference in New Issue
Block a user