naitokosuke · dotfiles

Claude Code's user-level configuration. settings.json, CLAUDE.md, the rules and the skills are read-only store symlinks, so Nix is the single source of truth and runtime edits are not persisted back. The binary comes from ./claude-sandbox.nix and the MCP integration from ./mcp.nix.

Preferences

Theme, editor mode, notifications and Japanese spinner verbs. The binary comes from the store (./claude-sandbox.nix), so nothing may update it in place: env turns off the auto-updater and the installation checks, which are the variables Claude Code reads for that. The llm-agents wrapper exports them too; these also cover a claude started without it (#485).

lines 23–49
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49    theme = "dark-daltonized";
    verbose = false;
    preferredNotifChannel = "auto";
    shiftEnterKeyBindingInstalled = true;
    editorMode = "normal";
    spinnerVerbs = {
      mode = "replace";
      verbs = [
        "考え中"
        "深く考え中"
        "実装中"
        "リファクタリング中"
        "調査中"
      ];
    };
    hasUsedBackslashReturn = true;
    autoCompactEnabled = true;
    diffTool = "auto";
    env = {
      DISABLE_AUTOUPDATER = "1";
      DISABLE_INSTALLATION_CHECKS = "1";
    };
    todoFeatureEnabled = true;
    messageIdleNotifThresholdMs = 60000;
    autoConnectIde = false;
    autoInstallIdeExtension = true;
    checkpointingEnabled = true;

Permissions

Denied outright rather than asked: reading credentials, wiping / or ~, force-pushing, and raw curl / wget in favour of WebFetch with an explicit domain, plus a tongue-in-cheek ban on perl and python.

lines 54–85
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85    permissions = {
      deny = [
        # Joke: discourage legacy / non-preferred runtimes
        "Bash(perl:*)"
        "Bash(python:*)"
        "Bash(python3:*)"

        "Read(.env)"
        "Read(.env.*)"
        "Read(./secrets/**)"
        "Read(**/credentials.json)"
        "Read(~/.ssh/**)"
        "Read(~/.aws/**)"
        "Read(~/.gnupg/**)"

        # Destructive shell — root / home wipes still trip the circuit breaker,
        # but make it explicit
        "Bash(rm -rf /:*)"
        "Bash(rm -rf ~:*)"
        "Bash(rm -rf ~/:*)"

        # Regular push stays in `ask`/allow
        "Bash(git push --force:*)"
        "Bash(git push -f:*)"
        "Bash(git push * --force:*)"
        "Bash(git push * -f:*)"

        # Prefer WebFetch with explicit domain over raw curl/wget
        "Bash(curl:*)"
        "Bash(wget:*)"
      ];
    };

Plan hook

A PreToolUse hook on ExitPlanMode opens the newest plan in VS Code, so a plan can be read in the editor before it is approved. code comes from the cask through /opt/homebrew/bin (environment.systemPath in hosts/common/homebrew.nix), which naitokosuke.requiredCasks above ties this module to. With no plan file the glob would be passed through literally, so the match is tested before opening anything — the hook is best-effort, and a failure here is quiet enough to stay unnoticed. ./adrafinil.nix and ./claude-rm-guard merge their hooks in alongside.

lines 95–108
95
96
97
98
99
100
101
102
103
104
105
106
107
108    hooks = {
      PreToolUse = [
        {
          matcher = "ExitPlanMode";
          hooks = [
            {
              type = "command";
              command = ''plan=$(ls -t ~/.claude/plans/*.md 2>/dev/null | head -1); [ -n "$plan" ] && code "$plan" || true'';
              timeout = 5;
            }
          ];
        }
      ];
    };

Rules and skills

CLAUDE.md and the rules live in ./claude-context and are installed from the store, so they cannot dangle (#535). Skills come from the locked skill-skill-skill input, the single source for both their names and their content, so a skill change arrives with nix flake update skill-skill-skill home-manager links the files one by one, which leaves room for the MCP plugin it installs into the same directory.

lines 119–121
119
120
121  programs.claude-code.context = ./claude-context/CLAUDE.md;
  programs.claude-code.rulesDir = ./claude-context/rules;
  programs.claude-code.skills = "${inputs.skill-skill-skill}/.claude/skills";
View the complete file123 lines · claude.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123# Claude Code's user-level configuration. settings.json, CLAUDE.md, the rules
# and the skills are read-only store symlinks, so Nix is the single source of
# truth and runtime edits are not persisted back. The binary comes from
# ./claude-sandbox.nix and the MCP integration from ./mcp.nix.
{
  inputs,
  ...
}:

{
  naitokosuke.requiredCasks.visual-studio-code = "home/claude.nix runs `code` in its plan hook";

  programs.claude-code.enable = true;

  programs.claude-code.settings = {
    ## Preferences
    # Theme, editor mode, notifications and Japanese spinner verbs. The binary
    # comes from the store (./claude-sandbox.nix), so nothing may update it in
    # place: `env` turns off the auto-updater and the installation checks,
    # which are the variables Claude Code reads for that. The llm-agents
    # wrapper exports them too; these also cover a `claude` started without it
    # (#485).
    theme = "dark-daltonized";
    verbose = false;
    preferredNotifChannel = "auto";
    shiftEnterKeyBindingInstalled = true;
    editorMode = "normal";
    spinnerVerbs = {
      mode = "replace";
      verbs = [
        "考え中"
        "深く考え中"
        "実装中"
        "リファクタリング中"
        "調査中"
      ];
    };
    hasUsedBackslashReturn = true;
    autoCompactEnabled = true;
    diffTool = "auto";
    env = {
      DISABLE_AUTOUPDATER = "1";
      DISABLE_INSTALLATION_CHECKS = "1";
    };
    todoFeatureEnabled = true;
    messageIdleNotifThresholdMs = 60000;
    autoConnectIde = false;
    autoInstallIdeExtension = true;
    checkpointingEnabled = true;
    ## Permissions
    # Denied outright rather than asked: reading credentials, wiping / or ~,
    # force-pushing, and raw curl / wget in favour of WebFetch with an explicit
    # domain, plus a tongue-in-cheek ban on perl and python.
    permissions = {
      deny = [
        # Joke: discourage legacy / non-preferred runtimes
        "Bash(perl:*)"
        "Bash(python:*)"
        "Bash(python3:*)"

        "Read(.env)"
        "Read(.env.*)"
        "Read(./secrets/**)"
        "Read(**/credentials.json)"
        "Read(~/.ssh/**)"
        "Read(~/.aws/**)"
        "Read(~/.gnupg/**)"

        # Destructive shell — root / home wipes still trip the circuit breaker,
        # but make it explicit
        "Bash(rm -rf /:*)"
        "Bash(rm -rf ~:*)"
        "Bash(rm -rf ~/:*)"

        # Regular push stays in `ask`/allow
        "Bash(git push --force:*)"
        "Bash(git push -f:*)"
        "Bash(git push * --force:*)"
        "Bash(git push * -f:*)"

        # Prefer WebFetch with explicit domain over raw curl/wget
        "Bash(curl:*)"
        "Bash(wget:*)"
      ];
    };
    ## Plan hook
    # A PreToolUse hook on ExitPlanMode opens the newest plan in VS Code, so a
    # plan can be read in the editor before it is approved. `code` comes from
    # the cask through /opt/homebrew/bin (environment.systemPath in
    # hosts/common/homebrew.nix), which `naitokosuke.requiredCasks` above ties
    # this module to. With no plan file the glob would be passed through
    # literally, so the match is tested before opening anything — the hook is
    # best-effort, and a failure here is quiet enough to stay unnoticed.
    # ./adrafinil.nix and ./claude-rm-guard merge their hooks in alongside.
    hooks = {
      PreToolUse = [
        {
          matcher = "ExitPlanMode";
          hooks = [
            {
              type = "command";
              command = ''plan=$(ls -t ~/.claude/plans/*.md 2>/dev/null | head -1); [ -n "$plan" ] && code "$plan" || true'';
              timeout = 5;
            }
          ];
        }
      ];
    };
  };

  ## Rules and skills
  # CLAUDE.md and the rules live in ./claude-context and are installed from
  # the store, so they cannot dangle (#535). Skills come from the locked
  # skill-skill-skill input, the single source for both their names and their
  # content, so a skill change arrives with
  #   nix flake update skill-skill-skill
  # home-manager links the files one by one, which leaves room for the MCP
  # plugin it installs into the same directory.
  programs.claude-code.context = ./claude-context/CLAUDE.md;
  programs.claude-code.rulesDir = ./claude-context/rules;
  programs.claude-code.skills = "${inputs.skill-skill-skill}/.claude/skills";
}
123 lines·4,302 chars·NIX