Set up JSONC workflow for Claude Code settings
Sets up a JSONC workflow for Claude Code settings with comments support. Use this when you need to maintain settings.json with comments in git repos, dotfiles, or global configurations.
/plugin marketplace add bengous/claude-code-plugins/plugin install claude-settings-manager@bengous-pluginsclaude-opus-4-5You are setting up a JSONC workflow for Claude Code settings in this repository.
Claude Code's settings.json doesn't support comments. This workflow:
__settings.jsonc as the editable source (supports // and /* */ comments)settings.json via hooksExplore the repo to understand its structure. Check:
Repo type detection:
.chezmoi.yaml.tmpl, .chezmoi.toml.tmpl, or .chezmoiroot? (chezmoi dotfiles)dot_* prefixed directories? (chezmoi dotfiles)stow or package-based structure? (stow dotfiles)Existing settings:
.claude/settings.json exist?~/.claude/settings.json exist (global)?__settings.jsonc file?Hook system:
lefthook.yml or lefthook.yaml?.husky/ directory?Project structure:
package.json?Use ls, Glob, and Read to explore. Example commands:
ls -la
ls -la .claude/ 2>/dev/null || echo "No .claude directory"
Based on your analysis, determine the appropriate flags:
For regular projects:
--source .claude/__settings.jsonc--target .claude/settings.json--hook-system lefthook (or husky if .husky/ exists)--scripts-path scripts/claudeFor chezmoi dotfiles:
--source dot_claude/__settings.jsonc--target dot_claude/settings.json--hook-system chezmoi--install-global (optional, installs settings-manager to PATH)For stow dotfiles:
--source <package>/__settings.jsonc (e.g., claude/__settings.jsonc)--target <package>/settings.json--hook-system lefthook--scripts-path <package>/scriptsUse AskUserQuestion to clarify ambiguous situations:
If repo type is unclear:
Question: "What type of settings are you configuring?"
Options:
- "Project settings (.claude/settings.json for this repo)"
- "Global settings (~/.claude/settings.json via dotfiles)"
If both lefthook and husky exist:
Question: "Which hook system should I use?"
Options:
- "lefthook"
- "husky"
If dotfiles structure is ambiguous:
Question: "Where should the settings files be created?"
Options:
- [suggest based on structure]
Before executing, show the user:
I'll set up JSONC settings with:
Source: <path>
Target: <path>
Hook system: <type>
Scripts: <path>
Files to create:
- <source path> (JSONC with comments)
- <scripts path>/settings-sync.sh (sync script)
- <scripts path>/../git/block-settings-json.sh (block script)
Files to modify:
- <hook config file>
- .gitattributes
Use AskUserQuestion to confirm:
Question: "Proceed with this setup?"
Options:
- "Yes, create the files"
- "Preview first (dry-run)"
- "Cancel"
Run the settings-manager script with your determined flags:
"${CLAUDE_PLUGIN_ROOT}/scripts/settings-manager" setup \
--source <source_path> \
--target <target_path> \
--hook-system <type> \
--scripts-path <scripts_path>
Add --dry-run for preview mode.
Add --install-global for chezmoi setups if user wants it in PATH.
Explain what was created and provide next steps:
For git hooks (lefthook/husky):
Setup complete!
Created:
<source path>
<scripts created>
How it works:
1. Edit <source path> (supports // and /* */ comments)
2. Commit your changes - the hook auto-syncs to settings.json
3. Direct edits to settings.json are blocked
Manual sync: /settings-sync
Check sync: /settings-check
Validate: /settings-validate
For chezmoi:
Setup complete!
Created:
<source path>
run_onchange_after_claude-settings.sh.tmpl
How it works:
1. Edit <source path> in your dotfiles
2. Run 'chezmoi apply' - the run_onchange script syncs
3. Changes deploy to ~/.claude/settings.json
Manual sync: settings-manager sync --source ~/.claude/__settings.jsonc --target ~/.claude/settings.json