Skip to content

Conversation

@fx
Copy link
Owner

@fx fx commented Nov 6, 2025

Summary

  • Implements declarative npm package installation using chezmoi's data-driven approach
  • Adds @anthropic-ai/claude-code package to the default installation
  • Updates chezmoi-development skill documentation with package installation patterns
  • Adds comprehensive test coverage for npm package installation

Implementation

New Files:

  • .chezmoidata/packages.yaml - Declares npm packages to install
  • .chezmoiscripts/run_onchange_after_install-npm-packages.sh.tmpl - Installation script that runs when package list changes

Modified Files:

  • .claude/skills/chezmoi-development/SKILL.md - Added "Declarative Package Installation" section with npm example
  • test/verify-marketplace.sh - Added npm package verification
  • test/test-coder-existing.sh - Fixed test to use valid JSON in mock settings file

Key Features

  1. Data-Driven: Package declarations in YAML file separate from installation logic
  2. Change Detection: Uses run_onchange_ prefix so script only runs when package list changes
  3. Idempotent: Checks if packages are already installed before attempting installation
  4. Mise Integration: Uses mise exec to ensure npm commands work in mise-managed Node.js environment
  5. Extensible: Pattern easily adaptable to other package managers (apt, brew, pip)

Testing

All tests pass:

  • ✅ Non-Coder environment (fresh install)
  • ✅ Coder fresh install (with /shared/ seeding)
  • ✅ Coder existing ~/.claude (preserves user files)

Each test verifies:

  • Marketplace configuration
  • NPM package installation (@anthropic-ai/claude-code)

Documentation

Updated the chezmoi-development skill with comprehensive documentation:

  • Pattern explanation
  • Complete working example
  • Template variable naming conventions
  • Adaptability to other package managers

Copilot AI review requested due to automatic review settings November 6, 2025 05:08
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 adds declarative npm package installation to the chezmoi dotfiles setup. It introduces a new pattern for managing npm global packages through YAML configuration, automatically installing them when the package list changes.

  • Adds .chezmoidata/packages.yaml to declare npm packages
  • Creates run_onchange_after_install-npm-packages.sh.tmpl script for automatic installation
  • Extends test verification to check npm package installation

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
.chezmoidata/packages.yaml New YAML file declaring npm global packages (e.g., @anthropic-ai/claude-code)
.chezmoiscripts/run_onchange_after_install-npm-packages.sh.tmpl New script that installs npm packages when package list changes, with mise integration
test/verify-marketplace.sh Extended to verify npm package installation, supports both yq-based parsing and fallback
test/test-coder-existing.sh Updated test fixture to use valid JSON instead of plain text
.claude/skills/chezmoi-development/SKILL.md Added documentation for the declarative package installation pattern

@fx fx merged commit d6955fd into main Nov 6, 2025
3 checks passed
@fx fx deleted the feat/npm-package-installation branch November 6, 2025 05:26
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