This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a NixOS/Home Manager dotfiles repository using the Denix framework for modular configuration management. It supports multiple platforms (NixOS, macOS via nix-darwin, Home Manager) with unified configuration.
Use the nixos and context7 mcp for background info (both of these should be used atleast 3 times anytime you edit a nix file)
All commands should be run using nix develop -c <command> to ensure the proper shell environment is loaded.
nix develop -c lint- Run linting tools (statix, deadnix, nix flake check) (if on nixos, should runnixos-rebuild build --flake .for better results)nix develop -c dx- Edit the flake.nix filenix fmt- Format code using treefmt
- Individual program tests:
cd modules/programs/<program-name> && nix buildto test custom program builds - convert_img tests:
cd modules/programs/convert_img && python -m pytest tests/ - if you edit any program in
modules/programs/, you should run the edited program manually to ensure it works in addition to the tests.
# macOS
darwin-rebuild switch --flake . --show-trace
# Linux (Home Manager only)
nix build .#homeConfigurations.x86_64-linux.activationPackage
# NixOS
nixos-rebuild build --flake .Create development shells with:
nix flake init -t github:connerohnesorge/dotfiles#<template-name>Available templates: devshell, rust-shell, go-shell, go-templ-shell, remix-js-shell, laravel-shell, phoenix-shell
nix flake check- Validate flake outputs and check for errorsnix eval .#nixosConfigurations.<hostname>.config.system.build.toplevel- Check NixOS configuration evaluationnix show-derivation- Inspect derivation details for debugging buildsnixos-rebuild build --flake . --show-trace- Build without switching to catch configuration errors
The repository uses the Denix framework for modular configuration management, providing type-safe, composable modules with automatic discovery and loading.
Configuration Modules (modules/config/):
constants.nix- Read-only user constants (username, email, etc.)user.nix- User account configuration for NixOS and Darwinhosts.nix- Host type definitions and feature mapping systemargs.nix- Shared arguments between nixos and home-manager configurationshome.nix- Home Manager configuration patternsrices.nix- Theme system configuration
Feature Modules (modules/features/):
- System-level capabilities that can be enabled per-host
- Use
delib.modulewithsingleEnableOption falsepattern - Platform-specific sections:
nixos.ifEnabled,darwin.ifEnabled,home.ifEnabled - Examples:
engineer.nix,hyprland.nix,nvidia.nix,audio.nix,bluetooth.nix
Custom Program Modules (modules/programs/):
- Self-contained applications with source code and build expressions
- Cross-platform deployment support (nixos/darwin)
- Examples:
catls/(Ruby),cmbd/(Go),convert_img/(Python),dx/(shell script)
Host Configurations (hosts/):
- Use
delib.hostwith type classification (desktop/laptop/server) - Feature enablement through
myconfig.features.* - Platform-specific configuration sections
Theme Configurations (rices/):
- Use
delib.ricewith Stylix integration - Consistent theming across applications using Base16 color schemes
Module Creation:
delib.module {
name = "feature-name";
options.myconfig.features.featureName = singleEnableOption false;
nixos.ifEnabled = { /* NixOS config */ };
darwin.ifEnabled = { /* macOS config */ };
home.ifEnabled = { /* Home Manager config */ };
}Host Configuration:
delib.host {
type = "desktop"; # or "laptop", "server"
features = { featureName = true; };
rice = "dark";
nixos = { /* NixOS-specific config */ };
darwin = { /* Darwin-specific config */ };
}Custom Program Packaging:
delib.module {
name = "program-name";
nixos.ifEnabled.environment.systemPackages = [ pkgs.program-name ];
darwin.ifEnabled.environment.systemPackages = [ pkgs.program-name ];
}The flake.nix uses Denix's auto-discovery system:
denix.lib.configurations {
homeManagerUser = "connerohnesorge";
paths = [./hosts ./modules ./rices]; # Auto-discovery paths
}This automatically creates:
nixosConfigurationshomeConfigurationsdarwinConfigurations
Features automatically enable required programs:
engineer.enable = true→ enables development tools (dx,convert_img, etc.)hyprland.enable = true→ enables Wayland desktop with supporting tools- Dependencies resolved through the Denix module system
Conditional Configuration: Separate platform sections in modules Shared Configuration: Maximize reuse between platforms where possible Platform Detection: Automatic handling of nixos vs darwin differences
flake.nix- Main entry point with system configurationsmodules/config/constants.nix- User constants (username, email, etc.)modules/config/hosts.nix- Host type definitions and feature mappingsshell.nix- Development environment with custom scripts
Creating New Feature Modules:
- Create a new
.nixfile inmodules/features/ - Use the
delib.modulepattern withsingleEnableOption false - Define platform-specific configuration in
nixos.ifEnabled,darwin.ifEnabled,home.ifEnabledsections - Features are automatically discovered and can be enabled in host configurations
Creating Custom Program Modules:
- Create a directory in
modules/programs/with source code anddefault.nix - Define the package derivation with cross-platform support
- Export the module using
delib.modulepattern - Programs are automatically available after rebuild
Modifying Host Configurations:
- Edit files in
hosts/to enable/disable features - Use
myconfig.features.featureName = trueto enable features - Platform-specific settings go in
nixosordarwinsections
- Module Isolation: Each module should be self-contained with minimal external dependencies
- Platform Awareness: Always consider both nixos and darwin when creating modules
- Feature Dependencies: Let the Denix system handle automatic dependency resolution
- Theme Integration: Use Stylix-compatible configuration for consistent theming
- Type Safety: Leverage Nix's type system through proper option definitions
Templates provide isolated development environments for different languages/frameworks:
- Each template is a complete flake.nix with development dependencies
- Use for project-specific development without affecting system configuration
- Available for: Go, Rust, Elixir/Phoenix, Laravel, Remix.js, Lua, and general devshell
Instructions for AI coding assistants using Spectr for spec-driven development.
- Search existing work:
spectr spec list --long,spectr list(usergonly for full-text search) - Decide scope: new capability vs modify existing capability
- Pick a unique
change-id: kebab-case, verb-led (add-,update-,remove-,refactor-) - Scaffold:
proposal.md,tasks.md,design.md(only if needed), and delta specs per affected capability - Write deltas: use
## ADDED|MODIFIED|REMOVED|RENAMED Requirements; include at least one#### Scenario:per requirement - Validate:
spectr validate [change-id] --strictand fix issues - Request approval: Do not start implementation until proposal is approved
Create proposal when you need to:
- Add features or functionality
- Make breaking changes (API, schema)
- Change architecture or patterns
- Optimize performance (changes behavior)
- Update security patterns
Triggers (examples):
- "Help me create a change proposal"
- "Help me plan a change"
- "Help me create a proposal"
- "I want to create a spec proposal"
- "I want to create a spec"
Loose matching guidance:
- Contains one of:
proposal,change,spec - With one of:
create,plan,make,start,help
Skip proposal for:
- Bug fixes (restore intended behavior)
- Typos, formatting, comments
- Dependency updates (non-breaking)
- Configuration changes
- Tests for existing behavior
Workflow
- Review
spectr/project.md,spectr list, andspectr list --specsto understand current context. - Choose a unique verb-led
change-idand scaffoldproposal.md,tasks.md, optionaldesign.md, and spec deltas underspectr/changes/<id>/. - Draft spec deltas using
## ADDED|MODIFIED|REMOVED Requirementswith at least one#### Scenario:per requirement. - Run
spectr validate <id> --strictand resolve any issues before sharing the proposal.
Track these steps as TODOs and complete them one by one.
- Read proposal.md - Understand what's being built
- Read design.md (if exists) - Review technical decisions
- Read tasks.md - Get implementation checklist
- Implement tasks sequentially - Complete in order
- Confirm completion - Ensure every item in
tasks.mdis finished before updating statuses - Update checklist - After all work is done, set every task to
- [x]so the list reflects reality - Approval gate - Do not start implementation until the proposal is reviewed and approved
After deployment, create separate PR to:
- Move
changes/[name]/→changes/archive/YYYY-MM-DD-[name]/ - Update
specs/if capabilities changed - Use
spectr archive <change-id> --skip-specs --yesfor tooling-only changes (always pass the change ID explicitly) - Run
spectr validate --strictto confirm the archived change passes checks
Context Checklist:
- Read relevant specs in
specs/[capability]/spec.md - Check pending changes in
changes/for conflicts - Read
spectr/project.mdfor conventions - Run
spectr listto see active changes - Run
spectr list --specsto see existing capabilities
Before Creating Specs:
- Always check if capability already exists
- Prefer modifying existing specs over creating duplicates
- Use
spectr show [spec]to review current state - If request is ambiguous, ask 1–2 clarifying questions before scaffolding
- Enumerate specs:
spectr spec list --long(or--jsonfor scripts) - Enumerate changes:
spectr list(orspectr change list --json- deprecated but available) - Show details:
- Spec:
spectr show <spec-id> --type spec(use--jsonfor filters) - Change:
spectr show <change-id> --json --deltas-only
- Spec:
- Full-text search (use ripgrep):
rg -n "Requirement:|Scenario:" spectr/specs
# Essential commands
spectr list # List active changes
spectr list --specs # List specifications
spectr show [item] # Display change or spec
spectr validate [item] # Validate changes or specs
spectr archive <change-id> [--yes|-y] # Archive after deployment (add --yes for non-interactive runs)
# Project management
spectr init [path] # Initialize Spectr
spectr update [path] # Update instruction files
# Interactive mode
spectr show # Prompts for selection
spectr validate # Bulk validation mode
# Debugging
spectr show [change] --json --deltas-only
spectr validate [change] --strict--json- Machine-readable output--type change|spec- Disambiguate items--strict- Comprehensive validation--no-interactive- Disable prompts--skip-specs- Archive without spec updates--yes/-y- Skip confirmation prompts (non-interactive archive)
spectr/
├── project.md # Project conventions
├── specs/ # Current truth - what IS built
│ └── [capability]/ # Single focused capability
│ ├── spec.md # Requirements and scenarios
│ └── design.md # Technical patterns
├── changes/ # Proposals - what SHOULD change
│ ├── [change-name]/
│ │ ├── proposal.md # Why, what, impact
│ │ ├── tasks.md # Implementation checklist
│ │ ├── design.md # Technical decisions (optional; see criteria)
│ │ └── specs/ # Delta changes
│ │ └── [capability]/
│ │ └── spec.md # ADDED/MODIFIED/REMOVED
│ └── archive/ # Completed changes
New request?
├─ Bug fix restoring spec behavior? → Fix directly
├─ Typo/format/comment? → Fix directly
├─ New feature/capability? → Create proposal
├─ Breaking change? → Create proposal
├─ Architecture change? → Create proposal
└─ Unclear? → Create proposal (safer)
-
Create directory:
changes/[change-id]/(kebab-case, verb-led, unique) -
Write proposal.md:
# Change: [Brief description of change]
## Why
[1-2 sentences on problem/opportunity]
## What Changes
- [Bullet list of changes]
- [Mark breaking changes with **BREAKING**]
## Impact
- Affected specs: [list capabilities]
- Affected code: [key files/systems]- Create spec deltas:
specs/[capability]/spec.md
## ADDED Requirements
### Requirement: New Feature
The system SHALL provide...
#### Scenario: Success case
- **WHEN** user performs action
- **THEN** expected result
## MODIFIED Requirements
### Requirement: Existing Feature
[Complete modified requirement]
## REMOVED Requirements
### Requirement: Old Feature
**Reason**: [Why removing]
**Migration**: [How to handle]If multiple capabilities are affected, create multiple delta files under changes/[change-id]/specs/<capability>/spec.md—one per capability.
- Create tasks.md:
## 1. Implementation
- [ ] 1.1 Create database schema
- [ ] 1.2 Implement API endpoint
- [ ] 1.3 Add frontend component
- [ ] 1.4 Write tests- Create design.md when needed:
Create
design.mdif any of the following apply; otherwise omit it:
- Cross-cutting change (multiple services/modules) or a new architectural pattern
- New external dependency or significant data model changes
- Security, performance, or migration complexity
- Ambiguity that benefits from technical decisions before coding
Minimal design.md skeleton:
## Context
[Background, constraints, stakeholders]
## Goals / Non-Goals
- Goals: [...]
- Non-Goals: [...]
## Decisions
- Decision: [What and why]
- Alternatives considered: [Options + rationale]
## Risks / Trade-offs
- [Risk] → Mitigation
## Migration Plan
[Steps, rollback]
## Open Questions
- [...]CORRECT (use #### headers):
#### Scenario: User login success
- **WHEN** valid credentials provided
- **THEN** return JWT tokenWRONG (don't use bullets or bold):
- **Scenario: User login** ❌
**Scenario**: User login ❌
### Scenario: User login ❌Every requirement MUST have at least one scenario.
- Use SHALL/MUST for normative requirements (avoid should/may unless intentionally non-normative)
## ADDED Requirements- New capabilities## MODIFIED Requirements- Changed behavior## REMOVED Requirements- Deprecated features## RENAMED Requirements- Name changes
Headers matched with trim(header) - whitespace ignored.
- ADDED: Introduces a new capability or sub-capability that can stand alone as a requirement. Prefer ADDED when the change is orthogonal (e.g., adding "Slash Command Configuration") rather than altering the semantics of an existing requirement.
- MODIFIED: Changes the behavior, scope, or acceptance criteria of an existing requirement. Always paste the full, updated requirement content (header + all scenarios). The archiver will replace the entire requirement with what you provide here; partial deltas will drop previous details.
- RENAMED: Use when only the name changes. If you also change behavior, use RENAMED (name) plus MODIFIED (content) referencing the new name.
Common pitfall: Using MODIFIED to add a new concern without including the previous text. This causes loss of detail at archive time. If you aren't explicitly changing the existing requirement, add a new requirement under ADDED instead.
Authoring a MODIFIED requirement correctly:
- Locate the existing requirement in
spectr/specs/<capability>/spec.md. - Copy the entire requirement block (from
### Requirement: ...through its scenarios). - Paste it under
## MODIFIED Requirementsand edit to reflect the new behavior. - Ensure the header text matches exactly (whitespace-insensitive) and keep at least one
#### Scenario:.
Example for RENAMED:
## RENAMED Requirements
- FROM: `### Requirement: Login`
- TO: `### Requirement: User Authentication`"Change must have at least one delta"
- Check
changes/[name]/specs/exists with .md files - Verify files have operation prefixes (## ADDED Requirements)
"Requirement must have at least one scenario"
- Check scenarios use
#### Scenario:format (4 hashtags) - Don't use bullet points or bold for scenario headers
Silent scenario parsing failures
- Exact format required:
#### Scenario: Name - Debug with:
spectr show [change] --json --deltas-only
# Always use strict mode for comprehensive checks
spectr validate [change] --strict
# Debug delta parsing
spectr show [change] --json | jq '.deltas'
# Check specific requirement
spectr show [spec] --json -r 1# 1) Explore current state
spectr spec list --long
spectr list
# Optional full-text search:
# rg -n "Requirement:|Scenario:" spectr/specs
# rg -n "^#|Requirement:" spectr/changes
# 2) Choose change id and scaffold
CHANGE=add-two-factor-auth
mkdir -p spectr/changes/$CHANGE/{specs/auth}
printf "## Why\\n...\\n\\n## What Changes\\n- ...\\n\\n## Impact\\n- ...\\n" > spectr/changes/$CHANGE/proposal.md
printf "## 1. Implementation\\n- [ ] 1.1 ...\\n" > spectr/changes/$CHANGE/tasks.md
# 3) Add deltas (example)
cat > spectr/changes/$CHANGE/specs/auth/spec.md << 'EOF'
## ADDED Requirements
### Requirement: Two-Factor Authentication
Users MUST provide a second factor during login.
#### Scenario: OTP required
- **WHEN** valid credentials are provided
- **THEN** an OTP challenge is required
EOF
# 4) Validate
spectr validate $CHANGE --strictspectr/changes/add-2fa-notify/
├── proposal.md
├── tasks.md
└── specs/
├── auth/
│ └── spec.md # ADDED: Two-Factor Authentication
└── notifications/
└── spec.md # ADDED: OTP email notification
auth/spec.md
## ADDED Requirements
### Requirement: Two-Factor Authentication
...notifications/spec.md
## ADDED Requirements
### Requirement: OTP Email Notification
...- Default to <100 lines of new code
- Single-file implementations until proven insufficient
- Avoid frameworks without clear justification
- Choose boring, proven patterns
Only add complexity with:
- Performance data showing current solution too slow
- Concrete scale requirements (>1000 users, >100MB data)
- Multiple proven use cases requiring abstraction
- Use
file.ts:42format for code locations - Reference specs as
specs/auth/spec.md - Link related changes and PRs
- Use verb-noun:
user-auth,payment-capture - Single purpose per capability
- 10-minute understandability rule
- Split if description needs "AND"
- Use kebab-case, short and descriptive:
add-two-factor-auth - Prefer verb-led prefixes:
add-,update-,remove-,refactor- - Ensure uniqueness; if taken, append
-2,-3, etc.
| Task | Tool | Why |
|---|---|---|
| Find files by pattern | Glob | Fast pattern matching |
| Search code content | Grep | Optimized regex search |
| Read specific files | Read | Direct file access |
| Explore unknown scope | Task | Multi-step investigation |
- Run
spectr listto see active changes - Check for overlapping specs
- Coordinate with change owners
- Consider combining proposals
- Run with
--strictflag - Check JSON output for details
- Verify spec file format
- Ensure scenarios properly formatted
- Read project.md first
- Check related specs
- Review recent archives
- Ask for clarification
changes/- Proposed, not yet builtspecs/- Built and deployedarchive/- Completed changes
proposal.md- Why and whattasks.md- Implementation stepsdesign.md- Technical decisionsspec.md- Requirements and behavior
spectr list # What's in progress?
spectr show [item] # View details
spectr validate --strict # Is it correct?
spectr archive <change-id> [--yes|-y] # Mark complete (add --yes for automation)Remember: Specs are truth. Changes are proposals. Keep them in sync.