Skip to content

feat: manage claude settings.json via chezmoi modify_ script - #861

Merged
yxtay merged 8 commits into
mainfrom
feat/chezmoi-claude-settings
Jul 3, 2026
Merged

feat: manage claude settings.json via chezmoi modify_ script#861
yxtay merged 8 commits into
mainfrom
feat/chezmoi-claude-settings

Conversation

@yxtay

@yxtay yxtay commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds chezmoi/.chezmoitemplates/claude-settings.json with the desired Claude Code settings (model, fallback, env, permissions, sandbox, hooks, etc.) — credentials excluded since the repo is public
  • Adds chezmoi/private_dot_claude/modify_settings.json using the same mergeOverwrite pattern as modify_opencode.json, so chezmoi apply deep-merges the template over the live file without clobbering runtime-managed keys (enabledPlugins, extraKnownMarketplaces, credential env vars)

Settings included

  • model, fallbackModel, modelOverrides (trimmed to active models with [1m] context)
  • env (non-credential env vars: model IDs, OTEL config, feature flags)
  • Behavior flags: autoCompactEnabled, awaySummaryEnabled, fileCheckpointingEnabled, preferredNotifChannel
  • permissions (allow/ask lists, disableBypassPermissionsMode)
  • sandbox (enabled, weaker network isolation, generalised allowWrite paths)
  • statusLine, worktree

Test plan

  • Run chezmoi diff ~/.claude/settings.json — should show no diff (or only credential fields)
  • Run chezmoi apply — settings.json restored with correct values after wipe

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added new default AI assistant settings, including model selection, fallback behavior, and several interface toggles.
    • Enabled a safer sandboxed setup with limited write access to common development directories.
    • Added a status line command and updated the default worktree base reference.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@yxtay, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 20 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a1fbab2f-875b-42d7-8486-b4757160106d

📥 Commits

Reviewing files that changed from the base of the PR and between 67a925d and 3b86c39.

📒 Files selected for processing (8)
  • chezmoi/.chezmoiscripts/run_onchange_add_agent_skills.sh.tmpl
  • chezmoi/.chezmoiscripts/run_onchange_after_agent_plugins.sh.tmpl
  • chezmoi/.chezmoiscripts/run_onchange_install_opencode.sh.tmpl
  • chezmoi/.chezmoiscripts/run_onchange_setup_opencode.sh.tmpl
  • chezmoi/.chezmoitemplates/claude-settings.json
  • chezmoi/.chezmoitemplates/opencode-tui.json
  • chezmoi/private_dot_agents/skills/mcp-cli-usage/SKILL.md
  • chezmoi/private_dot_config/opencode/modify_tui.json
📝 Walkthrough

Walkthrough

Adds a new chezmoi template file defining default Claude settings (model, permissions, sandboxing, status line, worktree config) and a modify-template that merges stdin-provided overrides with these defaults using mergeOverwrite, outputting pretty-printed JSON.

Changes

Claude settings configuration

Layer / File(s) Summary
Base settings template and merge logic
chezmoi/.chezmoitemplates/claude-settings.json, chezmoi/private_dot_claude/modify_settings.json
New template defines model fallbacks, environment variables, UI toggles, sandbox/permission settings, and status line config; modify-template merges optional stdin JSON overrides over these defaults via mergeOverwrite and emits pretty JSON.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Chezmoi
  participant ModifySettings as modify_settings.json
  participant ClaudeSettings as claude-settings.json

  Chezmoi->>ModifySettings: apply .chezmoi.stdin
  ModifySettings->>ModifySettings: parse stdin JSON if non-empty
  ModifySettings->>ClaudeSettings: load default settings template
  ModifySettings->>ModifySettings: mergeOverwrite(defaults, stdin overrides)
  ModifySettings-->>Chezmoi: output merged pretty JSON
Loading

Poem

A rabbit hops with settings new,
JSON templates, fresh and true,
Merging defaults with a stdin cheer,
Sandboxed paths, the config's clear,
Hop hop hooray, the build draws near! 🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: managing Claude settings via a chezmoi modify script.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/chezmoi-claude-settings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

⚠️MegaLinter analysis: Success with warnings

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ BASH shfmt 3 0 0 0 0.01s
⚠️ JSON prettier 8 0 1 0 0.44s
⚠️ MARKDOWN markdownlint 6 0 2 0 0.51s
✅ MARKDOWN markdown-table-formatter 6 0 0 0 0.14s
✅ YAML prettier 10 0 0 0 0.45s

Detailed Issues

⚠️ MARKDOWN / markdownlint - 2 errors
chezmoi/private_dot_claude/modify_CLAUDE.md:1 error MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "{{- /*chezmoi:modify-template*..."]
chezmoi/private_dot_config/opencode/modify_AGENTS.md:1 error MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "{{- /*chezmoi:modify-template*..."]
⚠️ JSON / prettier - 1 error
chezmoi/.chezmoitemplates/claude-settings.json 62ms (unchanged)
chezmoi/.chezmoitemplates/opencode-tui.json 2ms (unchanged)
chezmoi/.chezmoitemplates/opencode.json 4ms (unchanged)
[error] chezmoi/private_dot_claude/modify_settings.json: SyntaxError: Unexpected token (1:2)
[error] > 1 | {{- /* chezmoi:modify-template */ -}}
[error]     |  ^
[error]   2 | {{- $current := dict -}}
[error]   3 | {{- if .chezmoi.stdin | trim -}}
[error]   4 | {{-   $current = fromJson .chezmoi.stdin -}}
chezmoi/private_dot_config/mcp/mcp_servers.json 4ms (unchanged)
[error] chezmoi/private_dot_config/opencode/modify_opencode.json: SyntaxError: Unexpected token (1:2)
[error] > 1 | {{- /* chezmoi:modify-template */ -}}
[error]     |  ^
[error]   2 | {{- $current := dict -}}
[error]   3 | {{- if .chezmoi.stdin | trim -}}
[error]   4 | {{-   $current = fromJson .chezmoi.stdin -}}
[error] chezmoi/private_dot_config/opencode/modify_tui.json: SyntaxError: Unexpected token (1:2)
[error] > 1 | {{- /* chezmoi:modify-template */ -}}
[error]     |  ^
[error]   2 | {{- $current := dict -}}
[error]   3 | {{- if .chezmoi.stdin | trim -}}
[error]   4 | {{-   $current = fromJson .chezmoi.stdin -}}
renovate.json 5ms (unchanged)

Notices

📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining SECURITY_SUGGESTIONS: false)

See detailed reports in MegaLinter artifacts

Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining FLAVOR_SUGGESTIONS: false)

  • Documentation: Custom Flavors
  • Command: npx mega-linter-runner@9.5.0 --custom-flavor-setup --custom-flavor-linters BASH_SHFMT,JSON_PRETTIER,MARKDOWN_MARKDOWNLINT,MARKDOWN_MARKDOWN_TABLE_FORMATTER,YAML_PRETTIER

MegaLinter is graciously provided by OX Security
Show us your support by starring ⭐ the repository

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a template for Claude Code settings (claude-settings.json) along with a chezmoi modify template (modify_settings.json) to merge these settings. The review feedback suggests optimizing the status line command by removing npx to avoid performance overhead, adding a JSON schema for editor autocomplete, and removing trailing slashes from sandbox directory paths to ensure compatibility across different sandboxing backends.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread chezmoi/.chezmoitemplates/claude-settings.json
Comment thread chezmoi/.chezmoitemplates/claude-settings.json
Comment thread chezmoi/.chezmoitemplates/claude-settings.json
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the size/M label Jul 3, 2026
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

⚠️MegaLinter analysis: Success with warnings

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ BASH bash-exec 3 0 0 0.01s
✅ BASH shellcheck 3 0 0 0.13s
✅ REPOSITORY checkov yes no no 22.91s
✅ REPOSITORY devskim yes no no 2.53s
✅ REPOSITORY dustilock yes no no 0.09s
✅ REPOSITORY gitleaks yes no no 1.41s
✅ REPOSITORY grype yes no no 47.37s
✅ REPOSITORY kingfisher yes no no 10.02s
⚠️ REPOSITORY osv-scanner yes 1 no 0.2s
✅ REPOSITORY secretlint yes no no 1.73s
✅ REPOSITORY syft yes no no 1.75s
✅ REPOSITORY trivy yes no no 9.8s
✅ REPOSITORY trivy-sbom yes no no 0.16s
✅ REPOSITORY trufflehog yes no no 4.51s

Detailed Issues

⚠️ REPOSITORY / osv-scanner - 1 error
Scanning dir .
Starting filesystem walk for root: /
End status: 41 dirs visited, 139 inodes visited, 0 Extract calls, 8.013258ms elapsed, 8.013458ms wall time
No package sources found, --help for usage information.

Notices

📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining SECURITY_SUGGESTIONS: false)

See detailed reports in MegaLinter artifacts

Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining FLAVOR_SUGGESTIONS: false)

  • Documentation: Custom Flavors
  • Command: npx mega-linter-runner@9.5.0 --custom-flavor-setup --custom-flavor-linters BASH_EXEC,BASH_SHELLCHECK,REPOSITORY_CHECKOV,REPOSITORY_DEVSKIM,REPOSITORY_DUSTILOCK,REPOSITORY_GITLEAKS,REPOSITORY_GRYPE,REPOSITORY_OSV_SCANNER,REPOSITORY_SECRETLINT,REPOSITORY_SYFT,REPOSITORY_TRIVY,REPOSITORY_TRIVY_SBOM,REPOSITORY_TRUFFLEHOG,REPOSITORY_KINGFISHER

MegaLinter is graciously provided by OX Security
Show us your support by starring ⭐ the repository

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

⚠️MegaLinter analysis: Success with warnings

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ ACTION actionlint 5 0 0 0.36s
✅ ACTION zizmor 5 0 0 0 0.84s
✅ BASH bash-exec 3 0 0 0.01s
✅ BASH shellcheck 3 0 0 0.12s
✅ BASH shfmt 3 0 0 0 0.02s
✅ COPYPASTE jscpd yes no no 0.82s
✅ EDITORCONFIG editorconfig-checker 67 0 0 0.06s
⚠️ JSON prettier 8 0 1 0 0.39s
✅ JSON v8r 8 0 0 3.54s
⚠️ MARKDOWN markdownlint 6 0 2 0 0.7s
✅ MARKDOWN markdown-table-formatter 6 0 0 0 0.27s
✅ REPOSITORY checkov yes no no 23.09s
✅ REPOSITORY gitleaks yes no no 1.08s
✅ REPOSITORY git_diff yes no no 0.04s
✅ REPOSITORY grype yes no no 46.6s
⚠️ REPOSITORY osv-scanner yes 1 no 0.18s
✅ REPOSITORY secretlint yes no no 1.29s
✅ REPOSITORY syft yes no no 2.62s
✅ REPOSITORY trivy yes no no 12.67s
✅ REPOSITORY trivy-sbom yes no no 0.22s
✅ REPOSITORY trufflehog yes no no 3.79s
⚠️ SPELL lychee 24 2 0 0.9s
✅ YAML prettier 10 0 0 0 0.54s
✅ YAML v8r 10 0 0 7.47s
✅ YAML yamllint 10 0 0 0.56s

Detailed Issues

⚠️ SPELL / lychee - 2 errors
📝 Summary
---------------------
🔍 Total...........21
🔗 Unique..........16
✅ Successful......19
⏳ Timeouts.........0
🔀 Redirected.......4
👻 Excluded.........0
❓ Unknown..........0
🚫 Errors...........2
⛔ Unsupported......2

Errors in chezmoi/.chezmoitemplates/opencode.json
[406] https://mcp.deepwiki.com/mcp (at 23:15) | Rejected status code: 406 Not Acceptable

Errors in chezmoi/private_dot_config/mcp/mcp_servers.json
[406] https://mcp.deepwiki.com/mcp (at 11:15) | Rejected status code: 406 Not Acceptable

Hint: Followed 4 redirects. You might want to consider replacing redirecting URLs with the resolved URLs. Use verbose mode (`-v`/`-vv`) to see redirection details.
Hint: You can configure accepted/rejected response codes with `-a` or `--accept`
⚠️ MARKDOWN / markdownlint - 2 errors
chezmoi/private_dot_claude/modify_CLAUDE.md:1 error MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "{{- /*chezmoi:modify-template*..."]
chezmoi/private_dot_config/opencode/modify_AGENTS.md:1 error MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "{{- /*chezmoi:modify-template*..."]
⚠️ REPOSITORY / osv-scanner - 1 error
Scanning dir .
Starting filesystem walk for root: /
End status: 41 dirs visited, 139 inodes visited, 0 Extract calls, 3.385496ms elapsed, 3.385706ms wall time
No package sources found, --help for usage information.
⚠️ JSON / prettier - 1 error
chezmoi/.chezmoitemplates/claude-settings.json 56ms (unchanged)
chezmoi/.chezmoitemplates/opencode-tui.json 3ms (unchanged)
chezmoi/.chezmoitemplates/opencode.json 6ms (unchanged)
[error] chezmoi/private_dot_claude/modify_settings.json: SyntaxError: Unexpected token (1:2)
[error] > 1 | {{- /* chezmoi:modify-template */ -}}
[error]     |  ^
[error]   2 | {{- $current := dict -}}
[error]   3 | {{- if .chezmoi.stdin | trim -}}
[error]   4 | {{-   $current = fromJson .chezmoi.stdin -}}
chezmoi/private_dot_config/mcp/mcp_servers.json 3ms (unchanged)
[error] chezmoi/private_dot_config/opencode/modify_opencode.json: SyntaxError: Unexpected token (1:2)
[error] > 1 | {{- /* chezmoi:modify-template */ -}}
[error]     |  ^
[error]   2 | {{- $current := dict -}}
[error]   3 | {{- if .chezmoi.stdin | trim -}}
[error]   4 | {{-   $current = fromJson .chezmoi.stdin -}}
[error] chezmoi/private_dot_config/opencode/modify_tui.json: SyntaxError: Unexpected token (1:2)
[error] > 1 | {{- /* chezmoi:modify-template */ -}}
[error]     |  ^
[error]   2 | {{- $current := dict -}}
[error]   3 | {{- if .chezmoi.stdin | trim -}}
[error]   4 | {{-   $current = fromJson .chezmoi.stdin -}}
renovate.json 8ms (unchanged)

Notices

📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining SECURITY_SUGGESTIONS: false)

See detailed reports in MegaLinter artifacts

Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining FLAVOR_SUGGESTIONS: false)

  • Documentation: Custom Flavors
  • Command: npx mega-linter-runner@9.5.0 --custom-flavor-setup --custom-flavor-linters ACTION_ACTIONLINT,ACTION_ZIZMOR,BASH_EXEC,BASH_SHELLCHECK,BASH_SHFMT,COPYPASTE_JSCPD,EDITORCONFIG_EDITORCONFIG_CHECKER,JSON_V8R,JSON_PRETTIER,MARKDOWN_MARKDOWNLINT,MARKDOWN_MARKDOWN_TABLE_FORMATTER,REPOSITORY_CHECKOV,REPOSITORY_GIT_DIFF,REPOSITORY_GITLEAKS,REPOSITORY_GRYPE,REPOSITORY_OSV_SCANNER,REPOSITORY_SECRETLINT,REPOSITORY_SYFT,REPOSITORY_TRIVY,REPOSITORY_TRIVY_SBOM,REPOSITORY_TRUFFLEHOG,SPELL_LYCHEE,YAML_PRETTIER,YAML_YAMLLINT,YAML_V8R

MegaLinter is graciously provided by OX Security
Show us your support by starring ⭐ the repository

yxtay and others added 4 commits July 3, 2026 15:21
- add json schema reference for editor autocomplete
- replace npx invocation with direct context-mode command
- remove trailing slashes from sandbox allowWrite paths

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
context-mode is not installed globally, only available via npx

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added size/L and removed size/M labels Jul 3, 2026
Comment thread chezmoi/.chezmoiscripts/run_onchange_setup_opencode.sh.tmpl Fixed
@yxtay

yxtay commented Jul 3, 2026

Copy link
Copy Markdown
Owner Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request configures Claude Code and Opencode settings, including agent plugins, skills, and custom templates. The feedback highlights a critical issue where AWS Bedrock model IDs in the Claude settings need to be prefixed with anthropic. or us.anthropic. instead of bedrock. to prevent resolution errors. Additionally, it is recommended to add checks for the existence of npm and npx in the setup scripts to avoid execution failures on systems where Node.js is not installed.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread chezmoi/.chezmoitemplates/claude-settings.json
Comment thread chezmoi/.chezmoiscripts/run_onchange_setup_opencode.sh.tmpl
Comment thread chezmoi/.chezmoiscripts/run_onchange_after_agent_plugins.sh.tmpl
fi

if ! command -v opencode >/dev/null; then
npm install --global opencode-ai
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants