AgentSkillsCN

machine-specific-config

在新机器上设置dotfiles,或为工作/家庭/不同环境创建基于主机名的配置覆盖时使用此功能。

SKILL.md
--- frontmatter
name: machine-specific-config
description: Use when setting up dotfiles on new machines or creating hostname-based configuration overrides for work/home/different environments

Machine-Specific Configuration Management

Overview

Multi-Machine Support: Same dotfiles repo works across multiple machines using hostname detection and automatic config overrides.

Core principle: Detect hostname → auto-load local/{hostname}.el → apply machine-specific overrides

When to Use

Use this skill when:

  • Setting up dotfiles on a new machine
  • Creating machine-specific settings
  • Debugging why config differs between machines
  • Understanding which hostname config is active
  • Separating work/home/personal configurations

Quick Reference

TaskHowDetails
Check hostname(system-name) in EmacsReturns current hostname
Machine variablejf/machine-nameStores detected hostname
Config fileemacs/local/{hostname}.elAuto-loaded during init
Create overrideCreate file, add setq/configRestart Emacs to load

Configuration Pattern

Setup New Machine

  1. Check hostname: Eval (system-name) in Emacs
  2. Create file: emacs/local/{hostname}.el
  3. Add overrides (see examples below)
  4. Restart Emacs (changes load automatically)

Override Examples

elisp
;; emacs/local/Mac.home.el

;; Machine-specific org-roam dailies
(setq org-roam-dailies-directory "dailies/Mac.home/")

;; Local paths
(setq my-documents-path "/Users/jefffarr/Documents/")

;; Machine-specific keybindings
(global-set-key (kbd "C-c h") 'home-function)

;; Package config override
(use-package some-package
  :config
  (setq package-setting 'home-value))

Common Machine-Specific Settings

CategoryExamples
Org-roamorg-roam-dailies-directory, org directories, capture templates
File PathsDocument roots, project workspaces, backup directories
PackagesDifferent configs for work/home, integrations, dev tools
DisplayMonitor settings, font sizes, themes, window rules

Multi-Environment Strategy

Environment Types

  • Work machines: Work org-roam, work packages
  • Personal machines: Home directories, personal tools
  • Cross-platform: Platform-specific paths/packages

Load Order

  1. Core modules (from jf/enabled-modules)
  2. All standard modules
  3. Machine config (automatic from local/{hostname}.el)

Debugging

Check current machine:

  • Variable: C-h v jf/machine-name
  • Returns: Current hostname

File not loading:

  • Verify filename matches hostname exactly
  • Check file exists in emacs/local/ directory
  • Restart Emacs after creating file

Override not working:

  • Machine configs load last (correct)
  • Verify variable name is correct
  • Check for typos in hostname

Common Mistakes

MistakeWhy BadFix
Wrong hostnameFile won't loadUse exact output of (system-name)
Too many overridesHard to maintainOnly override what's different
No documentationForget why override existsComment purpose of overrides
Secrets in fileSecurity riskKeep credentials out of repo
Duplicating base configMaintenance burdenOverride minimally

Best Practices

  • Minimal overrides: Only change what's actually different
  • Document purpose: Comment why settings are machine-specific
  • No secrets: Keep API keys and credentials out
  • Logical grouping: Keep related overrides together
  • Test isolation: Verify base config still works without overrides