Skip to content

Conversation

@fx
Copy link
Owner

@fx fx commented Nov 6, 2025

Summary

Adds comprehensive chezmoi development documentation and fixes a race condition with ~/.claude/settings.json management.

Changes

1. New chezmoi-development Skill

  • Comprehensive guide for using .chezmoidata for configuration data
  • Documents modify_ scripts for non-destructive file merging
  • Explains symlink_ prefix for declarative symlinks
  • Details chezmoi execution order to avoid race conditions
  • Includes troubleshooting section for common issues

2. Fix Race Condition with ~/.claude Directory

Problem: The run_before_00_remove-claude-symlink.sh.tmpl script was creating ~/.claude directory before chezmoi processed files, preventing symlinking and causing issues.

Solution:

  • Removed unnecessary run_before_ script (chezmoi auto-creates parent directories)
  • Changed from regular template to modify_ script for settings.json
  • New dot_claude/modify_settings.json.tmpl merges marketplace config with existing user settings

3. Preserve User Settings

The new modify_ script:

  • ✅ Reads existing settings from stdin (chezmoi provides current content)
  • ✅ Merges user customizations with required marketplace config
  • ✅ Creates file if missing (fresh installs)
  • ✅ Works with symlinked ~/.claude (Coder workspaces)

Test Results

All tests pass:

  • ✅ Non-Coder: Creates settings.json with marketplace config
  • ✅ Coder fresh install: Works with symlinked ~/.claude
  • ✅ Coder existing settings: Preserves user files and merges settings

Files Changed

  • Add .chezmoidata/claude.yaml - Configuration data for marketplace
  • Remove .chezmoiscripts/run_before_00_remove-claude-symlink.sh.tmpl - No longer needed
  • Add .claude/skills/chezmoi-development/SKILL.md - Comprehensive documentation
  • Add .claude/skills/chezmoi-development/references/chezmoidata-modify-example.md - Working example
  • Replace dot_claude/settings.json with dot_claude/modify_settings.json.tmpl - Non-destructive merging
  • Update CLAUDE.md - Document the skill

Copilot AI review requested due to automatic review settings November 6, 2025 03:18
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors Claude Code marketplace configuration to use chezmoi's .chezmoidata and modify_ script pattern for non-destructive settings management. Instead of overwriting ~/.claude/settings.json, the configuration is now merged with existing user settings.

Key changes:

  • Replaced static dot_claude/settings.json with a modify_ script that merges configuration
  • Moved configuration data to .chezmoidata/claude.yaml for better separation of data and logic
  • Added comprehensive documentation about the pattern in a new skill and reference document

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
dot_claude/settings.json Removed static configuration file (no longer needed with modify_ approach)
dot_claude/modify_settings.json.tmpl New merge script that combines marketplace config with existing user settings
.chezmoidata/claude.yaml Configuration data extracted from hardcoded JSON
.chezmoiscripts/run_before_00_remove-claude-symlink.sh.tmpl Removed as directory creation is now handled automatically by chezmoi
CLAUDE.md Updated documentation to explain the new merge-based approach
.claude/skills/chezmoi-development/SKILL.md New comprehensive skill documentation for chezmoi development patterns
.claude/skills/chezmoi-development/references/chezmoidata-modify-example.md New reference document with complete working example

- Add comprehensive chezmoi-development skill with documentation for .chezmoidata and modify scripts
- Replace dot_claude/settings.json with run_onchange_after_update-claude-settings.sh.tmpl
- Add .claude to .chezmoiignore to prevent management conflicts with symlinks
- Remove run_before_00_remove-claude-symlink.sh.tmpl that was breaking symlinks
- Configure fx/cc marketplace and enable fx-dev@fx-cc plugin by default
- Improve install.sh to detect and use local repository for testing
- Clear chezmoi state database and use --force flag to avoid prompts
- Suppress confusing "Cloning into" message when using local repository

This approach allows .claude to remain a symlink in Coder workspaces while still applying
settings updates via the run_onchange_after script, which works with both directories and symlinks.
@fx fx force-pushed the feat/chezmoi-skill-and-modify-script branch from b58f28c to bf00725 Compare November 6, 2025 04:20
@fx fx requested a review from Copilot November 6, 2025 04:21
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.

Comments suppressed due to low confidence (1)

.claude/skills/chezmoi-development/SKILL.md:1

  • This statement is only true for modify_ scripts, not for run_onchange_after_ scripts which must read from disk. Since this PR uses run_onchange_after_, this guidance is misleading and contradicts the actual implementation. Consider adding a clear section that explains the differences between modify_ and run_onchange_ approaches.
---

…error handling

Address Copilot PR review feedback:
- Update all documentation to correctly reference run_onchange_after_ instead of modify_
- Add comprehensive section in SKILL.md distinguishing between modify_ (stdin/stdout) and run_onchange_ (disk I/O) approaches
- Clarify when to use each approach (symlinked directories require run_onchange_)
- Fix install.sh error handling to properly capture chezmoi init failures
- Document why --force flag is necessary in install.sh (state cleanup on lines 45-52)
@fx fx merged commit 1c65576 into main Nov 6, 2025
3 checks passed
@fx fx deleted the feat/chezmoi-skill-and-modify-script branch November 6, 2025 04:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants