dancing-bear: Hook for Claude Code

.claude/settings.json

SessionStart is a hook for Claude Code from dancing-bear-show/dancing-bear. Its token cost is not measured, scanned A, original, MIT.

A session-start hook that checks whether the agent is working in an isolated Git worktree and records session ownership information.

In plain words
What is it for?
Use it at the start of agent sessions to enforce worktree setup and identify ownership conflicts.
Why use it?
It helps detect sessions that are not isolated or that may conflict with another session. The input does not provide enough detail to describe every check.

Hook for Claude Code

Written for Claude Code: SessionStart hook event.

This is dancing-bear-show/dancing-bear's own configuration. It tells Claude Code how to work on dancing-bear itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything dancing-bear configures →

One of 4 entries in settings.json upstream. Installing this one merges just its entry into your config; the other 3 are separate, each on its own page.

Reuse

Borrowing it

Nothing to install: this file belongs to dancing-bear-show/dancing-bear. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/dancing-bear-show/dancing-bear/main/.claude/settings.json
Clone the repo
git clone --depth 1 https://github.com/dancing-bear-show/dancing-bear

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for SessionStart

README.md
[![agentmods](https://agentmods.dev/badge/hooks/dancing-bear-show/dancing-bear/session-start/github.svg)](https://agentmods.dev/hooks/dancing-bear-show/dancing-bear/session-start)
Your own site
<a href="https://agentmods.dev/hooks/dancing-bear-show/dancing-bear/session-start"><img src="https://agentmods.dev/badge/hooks/dancing-bear-show/dancing-bear/session-start/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for SessionStart

Your own site · 80×15
<a href="https://agentmods.dev/hooks/dancing-bear-show/dancing-bear/session-start"><img src="https://agentmods.dev/badge/hooks/dancing-bear-show/dancing-bear/session-start.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session not measured What this adds to a session before it is invoked.
When invoked not measured Not applicable: nothing here is loaded into a session.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Security

Grade A, and why

SessionStart scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the commands this hook runs, not an audit. A hook is shell that executes on your machine at the event it names, which is why every command in it is printed with what was found.

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

"command": "python3 -I -S -c \"\nimport subprocess, json, os, tempfile, time, uuid\ncommon_dir = subprocess.run(['git', 'rev-parse', '--git-common-dir'], capture_output=True, text=True).stdout.strip()\nmain = os.path.dir
.claude/settings.json · 21 lines

How it starts

The opening of the file, as written. The whole thing — 21 lines — stays where its author put it; the contents beside it link to each section on GitHub.

{
  "SessionStart": [
    {
      "hooks": [
        {
          "type": "command",
          "command": "python3 -I -S -c \"\nimport subprocess, json, os, tempfile, time, uuid\ncommon_dir = subprocess.run(['git', 'rev-parse', '--git-common-dir'], capture_output=True, text=True).stdout.strip()\nmain = os.path.dirname(os.path.abspath(common_dir)) if common_dir else None\ncwd = subprocess.run(['git', 'rev-parse', '--show-toplevel'], capture_output=True, text=True).stdout.strip()\nif main is None or cwd == main:\n    msg = {'systemMessage': 'ACTION REQUIRED: No worktree detected. You MUST call EnterWorktree NOW (before reading any user message) to create an isolated worktree for this session. Do not wait - call EnterWorktree immediately as your very first action.'}\nelse:\n    marker = os.path.join(cwd, '.claude', '.session-owner')\n    my_id = str(uuid.uuid4())\n    # Three outcomes, not two. A marker that EXISTS but cannot be read is not the\n    # same as no marker: it is stronger evidence of a collision, since the usual\n    # causes are two sessions writing concurrently or one dying mid-write.\n    # Swallowing that into the 'no marker' branch reported 'no action needed'\n    # exactly when the warning mattered most.\n    prev = None\n    unreadable = None\n    if os.path.exists(marker):\n        try:\n            with open(marker) as f:\n                loaded = json.load(f)\n            if isinstance(loaded, dict) and 'claimed_at' in loaded:\n                prev = loaded\n            else:\n                unreadable = 'unexpected contents'\n        except (OSError, IsADirectoryError) as e:\n            # A directory at this path, or an unreadable file, raises here rather\n            # than as a JSON error - a distinct failure mode worth naming.\n            unreadable = 'unreadable (' + type(e).__name__ + ')'\n        except Exception:\n            unreadable = 'not valid JSON'\n    os.makedirs(os.path.dirname(marker), exist_ok=True)\n    # Atomic write: a ki

Read the full file on GitHub · 21 lines

Same file

What else settings.json configures

This page is one entry in a file that holds 4. Installing the file brings all of them; each is measured and scanned on its own page.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 21 lines scan A 83a5c075c7b4

Subscribe to this mod's changes

SessionStart is a hook published in the GitHub repository dancing-bear-show/dancing-bear (7 stars, last pushed yesterday), licensed MIT. Its token cost is not measured: a hook is shell that never enters the context. A static security scan graded it A with 1 finding (runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-11-07.

Related

SessionStart compared with hooks from other repositories

SessionStart next to 6 hooks from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
SessionStartdancing-bear-show/dancing-bearHook7yesterdayMITA—Claude Code
SessionStartsupabase/supabaseHook115ktodayApache-2.0A—Claude Code
PostToolUsesupabase/supabaseHook115ktodayApache-2.0A—Claude Code
SessionStartgoogle-gemini/gemini-cliHook109ktodayApache-2.0A—Claude Code
PreToolUseapache/supersetHook75ktodayApache-2.0A—Claude Code
PostToolUseanthropics/claude-plugins-officialHook46ktodayApache-2.0A—Claude Code
PreToolUseanthropics/claude-cookbooksHook54k3d agoMITA—Claude Code