Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Dotfiles Project - Copilot Instructions

## Project Overview

This is a dotfiles management project that provides automated setup and configuration for macOS and Linux development environments. The project uses Make for orchestration, shell scripts for system configuration, and Homebrew for package management.

## General Coding Standards

- Follow Unix philosophy: write programs that do one thing well
- Use clear, descriptive variable and function names
- Add comments for complex logic and non-obvious decisions
- Maintain backward compatibility when modifying existing scripts
- Test changes on both macOS and Linux when applicable

## Shell Scripting Guidelines

- Use `#!/usr/bin/env bash` for portability
- Set strict error handling: `set -euo pipefail`
- Quote all variables to prevent word splitting: `"${variable}"`
- Use `[[` instead of `[` for conditionals in bash
- Prefer `$()` over backticks for command substitution
- Check for command existence before using: `command -v tool &> /dev/null`

## File Organization

- **bin/**: Utility scripts and dotfiles management commands
- **config/**: Application configuration files (git, prettier, etc.)
- **install/**: Package lists and installation manifests
- **macos/**: macOS-specific configuration scripts
- **runcom/**: Shell configuration files (e.g., .bashrc, .zshrc equivalents)
- **system/**: System-level configuration and setup scripts

## Makefile Standards

- Use `.PHONY` targets for non-file targets
- Add help text for each target
- Keep targets focused on single responsibilities
- Use `@` prefix to suppress command echo for clean output
- Check for required dependencies before executing

## Dependencies and Package Management

- Homebrew packages go in `install/Brewfile`
- Cask applications go in `install/Caskfile`
- Node/NPM global packages go in `install/npmfile`
- VS Code extensions go in `install/VSCodefile`
- Version-managed tools use asdf and are defined in `runcom/.tool-versions`

## Testing

- All scripts should handle missing dependencies gracefully
- Test on fresh installations when possible
- CI/CD tests run on both Ubuntu and macOS via GitHub Actions
- Use the `test/` directory for automated tests using bats framework

## Documentation

- Update README.md when adding new features or commands
- Add inline comments for complex shell logic
- Document any system requirements or prerequisites
- Include usage examples for new scripts or commands
34 changes: 34 additions & 0 deletions .github/instructions/documentation.instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
description: Documentation standards for README and markdown files
applyTo: "**/*.md"
---

# Documentation Standards

## README Files

- Start with clear project description
- Include installation instructions
- Document all available commands and features
- Add examples for common use cases
- Keep formatting consistent with existing style

## Inline Comments

- Add comments for complex logic
- Document non-obvious decisions
- Explain "why" not just "what"
- Keep comments up-to-date with code changes

## Code Examples

- Use proper markdown code blocks with language specifiers
- Test all code examples to ensure they work
- Include expected output when relevant

## Structure

- Use proper heading hierarchy (H1 -> H2 -> H3)
- Add table of contents for long documents
- Use lists for multiple related items
- Use tables for structured data
36 changes: 36 additions & 0 deletions .github/instructions/makefile.instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
description: Makefile conventions for this project
applyTo: "**/Makefile,**/*.mk"
---

# Makefile Standards

## Target Conventions

- Use `.PHONY` declaration for non-file targets
- Add descriptive comments above each target for help documentation
- Keep target names lowercase with hyphens for multi-word names

## Command Formatting

- Use `@` prefix to suppress command echo for clean output
- Add `@echo` statements to inform users of progress
- Check for required dependencies before executing commands

## Variables

- Define variables at the top of the file
- Use `:=` for simple expansion, `=` for recursive expansion
- Document purpose of non-obvious variables

## Dependency Management

- Check for required tools before using them
- Provide helpful error messages when dependencies are missing
- Example: `command -v brew >/dev/null 2>&1 || { echo "Homebrew required"; exit 1; }`

## Target Organization

- Group related targets together
- Keep targets focused on single responsibilities
- Use target dependencies for proper execution order
41 changes: 41 additions & 0 deletions .github/instructions/shell-scripts.instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
description: Shell scripting standards for Bash/Zsh scripts
applyTo: "**/*.sh,bin/*"
---

# Shell Scripting Standards

## Script Headers

- Always include shebang: `#!/usr/bin/env bash` for portability
- Set strict error handling at the top: `set -euo pipefail`
- Add brief description comment after shebang

## Variable Handling

- Always quote variables: `"${variable}"` to prevent word splitting
- Use `${variable}` syntax instead of `$variable` for clarity
- Declare local variables in functions: `local var_name`
- Use uppercase for environment variables, lowercase for local variables

## Conditionals

- Use `[[` instead of `[` for test conditions in bash
- Prefer explicit conditions: `[[ -n "${var}" ]]` instead of `[[ "${var}" ]]`

## Command Substitution

- Use `$()` instead of backticks for command substitution
- Check command existence: `command -v tool &> /dev/null` or `type tool &> /dev/null`

## Error Handling

- Check exit codes for critical commands
- Provide meaningful error messages
- Clean up temporary files/resources on exit using trap

## Functions

- Use descriptive function names with underscores
- Document function purpose with comments
- Keep functions focused on single responsibility
31 changes: 31 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,36 @@ link: stow-$(OS)
stow -t $(HOME) runcom
stow -t $(XDG_CONFIG_HOME) config

copilot: stow-$(OS)
@echo "Setting up GitHub Copilot custom instructions and chat modes..."
# Remove existing symlinks in the prompts directory
mkdir -p "$(HOME)/Library/Application Support/Code - Insiders/User/prompts"
find "$(HOME)/Library/Application Support/Code - Insiders/User/prompts/" -type l -exec rm {} \;
# Link user-level instructions
if [ -d "$(DOTFILES_DIR)/config/copilot/instructions" ]; then \
for FILE in $(DOTFILES_DIR)/config/copilot/instructions/*.instructions.md; do \
ln -sf "$$FILE" "$(HOME)/Library/Application Support/Code - Insiders/User/prompts/$$(basename $$FILE)"; \
done; \
echo "✓ Linked user-level instructions"; \
fi
# Link user-level chat modes
if [ -d "$(DOTFILES_DIR)/config/copilot/chatmodes" ]; then \
for FILE in $(DOTFILES_DIR)/config/copilot/chatmodes/*.chatmode.md; do \
ln -sf "$$FILE" "$(HOME)/Library/Application Support/Code - Insiders/User/prompts/$$(basename $$FILE)"; \
done; \
echo "✓ Linked user-level chat modes"; \
fi
# Link custom agent files
if [ -d "$(DOTFILES_DIR)/config/copilot/agents" ]; then \
for FILE in $(DOTFILES_DIR)/config/copilot/agents/*.agent.md; do \
ln -sf "$$FILE" "$(HOME)/Library/Application Support/Code - Insiders/User/prompts/$$(basename $$FILE)"; \
done; \
echo "✓ Linked custom agent files"; \
fi
@echo "✓ GitHub Copilot configuration complete!"
@echo ""
@echo "All chat modes and instructions are now available globally in VS Code Insiders."

unlink: stow-$(OS)
stow --delete -t $(HOME) runcom
stow --delete -t $(XDG_CONFIG_HOME) config
Expand Down Expand Up @@ -102,3 +132,4 @@ node-packages: asdf

test:
bats test

70 changes: 69 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ It mainly targets macOS systems, but it works on at least Ubuntu as well.
- Mostly based around Homebrew, Cask, ASDF, NPM, latest Bash + GNU Utils
- Fast and colored prompt
- Updated macOS defaults (Dock, Systen)
- Interactive macOS setup now prompts for computer name (with fallback and env override)
- GitHub Copilot custom instructions, custom agent files, and chat modes (plan, agent, review, test, document) for enhanced AI assistance
- The installation and runcom setup is
[tested on real Ubuntu and macOS machines](https://github.com/ntsd/dotfiles/actions) using
[a GitHub Action](./.github/workflows/ci.yml)
Expand All @@ -25,6 +27,48 @@ It mainly targets macOS systems, but it works on at least Ubuntu as well.
- [Vs Code](https://github.com/microsoft/vscode) (packages: [VSCodefile](./install/VSCodefile))
- Latest Git, Bash 4, GNU coreutils, curl

## GitHub Copilot Configuration

This dotfiles repository includes comprehensive GitHub Copilot customizations to enhance your AI-assisted coding experience.

### Workspace-Level Instructions

Located in `.github/`, these apply automatically to this workspace:

- **[copilot-instructions.md](./.github/copilot-instructions.md)**: Main coding standards and project guidelines
- **[instructions/](./.github/instructions/)**: File-type specific instructions
- `shell-scripts.instructions.md`: Shell scripting standards
- `makefile.instructions.md`: Makefile conventions
- `documentation.instructions.md`: Documentation guidelines

### Custom Chat Modes

Located in `.github/chatmodes/`, these provide specialized AI personas:

- **agent**: Implementation mode (makes code changes, runs commands, hands off to review/test/document)
- **plan**: Generate detailed implementation plans without making code changes
- **review**: Perform thorough code reviews focusing on quality and security
- **test**: Create comprehensive test cases using the bats framework
- **document**: Generate clear documentation with examples

### User Profile Instructions

Located in `config/copilot/`, these sync across all your workspaces:

- **instructions/general.instructions.md**: Personal coding standards for all projects
- **chatmodes/debug.chatmode.md**: Quick debugging and troubleshooting
- **chatmodes/explain.chatmode.md**: Detailed code and concept explanations
- **chatmodes/agent.chatmode.md**: Personal implementation mode available across all workspaces
- **agents/**: Place `*.agent.md` custom agent persona files here (linked by `make copilot`)

To deploy user profile configurations:

```bash
make copilot
```

This will symlink the Copilot configurations to your VS Code user profile, making them available across all workspaces.

## Installation

On a sparkling fresh installation of macOS:
Expand Down Expand Up @@ -55,7 +99,13 @@ and [config](./config) (using [stow](https://www.gnu.org/software/stow/)):

```bash
cd ~/.dotfiles
make
COMPUTER_NAME="MyMac" make

# During `make macos` the defaults script will prompt:
# Enter desired computer name [CurrentName] (leave blank to keep):
# You can automate this by providing an environment variable:
# COMPUTER_NAME="MyMac" make macos
# If omitted, existing ComputerName or hostname is used.
```

## The `dotfiles` command
Expand All @@ -67,6 +117,7 @@ Usage: dotfiles <command>
Commands:
help This help message
clean Clean up caches (brew)
copilot Setup GitHub Copilot custom instructions and chat modes
dock Apply macOS Dock settings
macos Apply macOS system defaults
test Run tests
Expand All @@ -84,6 +135,23 @@ You can put your custom settings, such as Git credentials in the `system/.custom
Alternatively, you can have an additional, personal dotfiles repo at `~/.extra`. The runcom `.bash_profile` sources all
`~/.extra/*.sh` files.

### Copilot Configuration Deployment

Deploy workspace + user-level Copilot config (instructions, chat modes, agents):

```bash
make copilot
```

This links:
- `.github/copilot-instructions.md` and `.github/instructions/*.instructions.md`
- `.github/chatmodes/*.chatmode.md` (including `agent.chatmode.md`)
- `config/copilot/instructions/*.instructions.md`
- `config/copilot/chatmodes/*.chatmode.md`
- `config/copilot/agents/*.agent.md`

Add new custom agent personas by creating `config/copilot/agents/mypersona.agent.md` then re-run `make copilot`.

## Credits

This dotfile is fork from [@webpro Dotfiles](https://github.com/webpro/dotfiles).
Expand Down
5 changes: 5 additions & 0 deletions bin/dotfiles
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ sub_help () {
echo "Commands:"
echo " help This help message"
echo " clean Clean up caches (brew)"
echo " copilot Setup GitHub Copilot custom instructions and chat modes"
echo " dock Apply macOS Dock settings"
echo " macos Apply macOS system defaults"
echo " test Run tests"
Expand Down Expand Up @@ -42,6 +43,10 @@ sub_dock () {
. "${DOTFILES_DIR}/macos/dock.sh" && echo "Dock reloaded."
}

sub_copilot () {
cd ${DOTFILES_DIR} && make copilot
}

sub_asdf () {
cd ${DOTFILES_DIR} && make asdf-packages
}
Expand Down
Loading
Loading