Skip to content

Add GitHub Copilot/Claude instruction#583

Merged
agners merged 2 commits intomasterfrom
add-ai-instructions
Aug 12, 2025
Merged

Add GitHub Copilot/Claude instruction#583
agners merged 2 commits intomasterfrom
add-ai-instructions

Conversation

@agners
Copy link
Copy Markdown
Member

@agners agners commented Aug 12, 2025

SSIA

Summary by CodeRabbit

  • Documentation
    • Added a comprehensive project overview for the CLI covering repository structure and command categories.
    • Documented development setup, environment-based configuration, and build/test/format workflows.
    • Included architecture notes, testing guidelines, contribution practices, and supported usage contexts to streamline onboarding and PR quality.

Comment thread .github/copilot-instructions.md Outdated
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Aug 12, 2025

📝 Walkthrough

Walkthrough

Adds new documentation files (.github/copilot-instructions.md and CLAUDE.md) providing a project overview, repository structure, tech stack, command categories, development setup, build/test/format instructions, architecture notes, testing guidance, and contribution practices. No code, configuration, or public interfaces were changed.

Changes

Cohort / File(s) Summary
Documentation: Copilot instructions
/.github/copilot-instructions.md
Added a comprehensive markdown guide covering project overview, repo structure, technologies (Go, Cobra, Resty, Viper, Logrus), command categories, dev environment (API endpoint/token, optional config), build/test/format commands, file organization, architecture notes, testing guidelines, and contributing practices.
Repository note
/CLAUDE.md
Added a file referencing the addition of the copilot instructions doc (mirrors/notes the new documentation entry).

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 8fa0752 and 9e23947.

📒 Files selected for processing (1)
  • .github/copilot-instructions.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .github/copilot-instructions.md
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-ai-instructions

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🔭 Outside diff range comments (2)
CLAUDE.md (2)

3-81: Avoid duplicated, drifting documentation between CLAUDE.md and .github/copilot-instructions.md

This file duplicates the same guidance that already exists in .github/copilot-instructions.md. Keeping two near-identical sources will drift and create confusion.

Two options:

  • Preferred: Make CLAUDE.md a single-source pointer to the canonical file.
  • Alternative: Delete CLAUDE.md and keep .github/copilot-instructions.md only.

If keeping CLAUDE.md, replace the entire content with a short pointer:

-## Project Overview
-This is the official Home Assistant CLI tool written in Go, providing command-line
-interface to interact with the Home Assistant Supervisor. The CLI enables users to
-manage add-ons, control the core system, handle audio/network settings, manage
-backups, and perform various system operations.
-
-The CLI is communicating with the Supervisor using the Supervisor's HTTP REST API.
-
-## Repository Structure
-- **`main.go`** - Entry point of the application
-- **`cmd/`** - Contains all CLI command implementations using Cobra framework
-- **`client/`** - HTTP client functionality for API communication
-- **`spinner/`** - Progress spinner implementation
-- **Root files** - Configuration and documentation
-
-## Key Technologies
-- **Language**: Go 1.23+ (toolchain 1.24.1)
-- **CLI Framework**: Cobra (github.com/spf13/cobra)
-- **HTTP Client**: Resty (github.com/go-resty/resty/v2)
-- **Configuration**: Viper (github.com/spf13/viper)
-- **Logging**: Logrus (github.com/sirupsen/logrus)
-
-## Available Commands
-The CLI provides the following main command categories:
-- `addons` - Install, update, remove and configure Home Assistant add-ons
-- `audio` - Audio plug-in management
-- `authentication` - Authentication for Home Assistant users
-- `cli` - CLI plug-in management
-- `core` - Home Assistant Core control
-- `dns` - DNS plug-in management
-- `docker` - Docker related configuration
-- `hardware` - System hardware information
-- `host` - Host OS control
-- `info` - General Home Assistant information
-- `multicast` - Multicast plug-in configuration
-- `network` - Network configuration and management
-- `observer` - Observer plug-in management
-- `os` - Home Assistant OS specific operations
-- `resolution` - Resolution center for issues and solutions
-- `backups` - Backup creation, restoration, and management
-- `supervisor` - Supervisor monitoring and control
-
-## Development Environment
-- **API Endpoint**: Configurable via `SUPERVISOR_ENDPOINT` environment variable
-- **Authentication**: Uses API tokens via `SUPERVISOR_API_TOKEN` environment variable
-- **Config File**: Optional config file support (default: `$HOME/.homeassistant.yaml`)
-
-## Build Commands
-- **Build**: `CGO_ENABLED=0 go build -ldflags="-s -w" -o "ha"`
-- **Test**: `go test ./...`
-- **Format**: `gofmt -s`
-
-## File Organization Patterns
-- Command files follow naming pattern: `<component>_<action>.go`
-- Each command typically has its own file in the `cmd/` directory
-- Helper functions are in `client/helper.go`
-- Main client logic is in `client/client.go`
-
-## Architecture Notes
-- Uses Cobra for command structure and flag parsing
-- Resty for HTTP API calls to Home Assistant Supervisor
-- Viper for configuration management
-- Logrus for structured logging
-- Custom spinner implementation for progress indication
-
-## Testing
-- Unit tests available in `client/helper_test.go`
-- Test command: `go test ./...`
-
-## Contributing Guidelines
-1. Create feature branch
-2. Commit changes
-3. Rebase against master
-4. Run tests with `go test ./...`
-5. Format code with `gofmt -s`
-6. Create Pull Request
-
-This CLI is designed to work with Home Assistant Supervisor API and is commonly used in
-Home Assistant Operating System environments, SSH add-ons, and development setups.
+# Claude instructions
+
+This document intentionally points to a single source of truth for AI assistant guidance:
+
+See: .github/copilot-instructions.md

18-24: Consistent Versioning Verified – Recommend Referencing go.mod

We’ve confirmed that CLAUDE.md’s versions match go.mod exactly and all listed libraries are in use. To avoid manual drift, still consider pointing consumers at go.mod rather than hard-coding:

• File: CLAUDE.md (lines 18–24)

  • Current:
    - **Language**: Go 1.23+ (toolchain 1.24.1)
    + **Language**: Go (see go.mod for version)

This keeps documentation accurate without future updates whenever you bump the Go or toolchain version.

🧹 Nitpick comments (2)
CLAUDE.md (1)

72-76: Use ‘main’ instead of ‘master’ branch name

Home Assistant org repos typically use ‘main’. “Rebase against master” is likely outdated.

Apply:

-3. Rebase against master
+3. Rebase against main
.github/copilot-instructions.md (1)

72-76: Update “Rebase against master” to “main”

Most HA repos use ‘main’. “master” is likely outdated.

-3. Rebase against master
+3. Rebase against main
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 28d212e and 8fa0752.

📒 Files selected for processing (2)
  • .github/copilot-instructions.md (1 hunks)
  • CLAUDE.md (1 hunks)
🔇 Additional comments (5)
CLAUDE.md (3)

55-60: File References Verified

All referenced paths—client/helper.go, client/client.go, the spinner package, and the cmd/ directory—exist in the repository as expected. No further changes needed.


1-1: Remove stray filename literal at top of document

Line 1 looks like an accidental paste of a path rather than content. It renders as plain text in the doc and is confusing.

Apply this diff to remove the stray line:

-.github/copilot-instructions.md

Likely an incorrect or invalid review comment.


45-49: Default config file path and format verified

The documentation’s default of $HOME/.homeassistant.yaml aligns with the code:

  • The CLI flag help and README both state “default is $HOME/.homeassistant.yaml”
  • In cmd/root.go, when no --config is provided, Viper is pointed to $HOME and SetConfigName(".homeassistant"), which by default loads .homeassistant.yaml

No changes required.

.github/copilot-instructions.md (2)

1-81: Great addition; comprehensive and actionable for AI assistants

The overview, architecture, and development guidance are clear and will meaningfully improve AI-assisted contributions. Nice work.


56-60: Confirmed file layout claims in .github/copilot-instructions.md

The following paths exist in the repository, matching the documentation:

  • client/helper.go
  • client/client.go
  • spinner/
  • cmd/

No changes required.

Comment thread .github/copilot-instructions.md Outdated
Comment on lines +19 to +23
- **Language**: Go 1.23+ (toolchain 1.24.1)
- **CLI Framework**: Cobra (github.com/spf13/cobra)
- **HTTP Client**: Resty (github.com/go-resty/resty/v2)
- **Configuration**: Viper (github.com/spf13/viper)
- **Logging**: Logrus (github.com/sirupsen/logrus)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Avoid hard-coding Go/toolchain versions; defer to go.mod

Version details drift fast. Consider pointing to go.mod instead of specific numbers.

-**Language**: Go 1.23+ (toolchain 1.24.1)
+**Language**: See the required Go version declared in go.mod (and toolchain, if set).

To validate current versions and referenced libs:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Go version from go.mod:"
rg -n '^go [0-9]+\.[0-9]+' go.mod || true
rg -n '^toolchain ' go.mod || true

echo
echo "Check referenced libraries are present:"
for pkg in 'github.com/spf13/cobra' 'github.com/go-resty/resty/v2' 'github.com/spf13/viper' 'github.com/sirupsen/logrus'; do
  echo -n "$pkg: "
  if rg -n "$pkg" -A 1 -S >/dev/null; then echo "found"; else echo "NOT found"; fi
done

Length of output: 1269


Use go.mod for Go/toolchain versions

Hard-coding specific Go or toolchain versions can drift out of sync—defer to the declaration in go.mod instead.

Suggested update:

- **Language**: Go 1.23+ (toolchain 1.24.1)
+ **Language**: See go.mod for the required Go version (and any toolchain declaration)

All referenced libraries (Cobra, Resty, Viper, Logrus) are present in the codebase.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- **Language**: Go 1.23+ (toolchain 1.24.1)
- **CLI Framework**: Cobra (github.com/spf13/cobra)
- **HTTP Client**: Resty (github.com/go-resty/resty/v2)
- **Configuration**: Viper (github.com/spf13/viper)
- **Logging**: Logrus (github.com/sirupsen/logrus)
- **Language**: See go.mod for the required Go version (and any toolchain declaration)
- **CLI Framework**: Cobra (github.com/spf13/cobra)
- **HTTP Client**: Resty (github.com/go-resty/resty/v2)
- **Configuration**: Viper (github.com/spf13/viper)
- **Logging**: Logrus (github.com/sirupsen/logrus)
🤖 Prompt for AI Agents
.github/copilot-instructions.md lines 19-23: the file currently hard-codes a
Go/toolchain version and should instead defer to go.mod; remove the explicit "Go
1.23+ (toolchain 1.24.1)" wording and replace it with a short sentence
instructing readers to use the Go version declared in go.mod (or check go.mod
for the required Go/toolchain version), and leave the listed libraries (Cobra,
Resty, Viper, Logrus) without embedded toolchain versions—ensure the phrasing is
concise and instructive about consulting go.mod for versions.

Comment on lines +26 to +43
The CLI provides the following main command categories:
- `addons` - Install, update, remove and configure Home Assistant add-ons
- `audio` - Audio plug-in management
- `authentication` - Authentication for Home Assistant users
- `cli` - CLI plug-in management
- `core` - Home Assistant Core control
- `dns` - DNS plug-in management
- `docker` - Docker related configuration
- `hardware` - System hardware information
- `host` - Host OS control
- `info` - General Home Assistant information
- `multicast` - Multicast plug-in configuration
- `network` - Network configuration and management
- `observer` - Observer plug-in management
- `os` - Home Assistant OS specific operations
- `resolution` - Resolution center for issues and solutions
- `backups` - Backup creation, restoration, and management
- `supervisor` - Supervisor monitoring and control
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Optionally validate listed command categories against cobra definitions

To keep this list in sync, you can auto-check for top-level cobra “Use” strings.


🏁 Script executed:

#!/bin/bash
set -euo pipefail

declare -a cmds=(addons audio authentication cli core dns docker hardware host info multicast network observer os resolution backups supervisor)

missing=0
for c in "${cmds[@]}"; do
  if rg -n $'Use:\\s*"'$c'"' -S >/dev/null; then
    echo "$c"
  else
    echo "$c (not found in code)"
    missing=1
  fi
done

exit $missing

Length of output: 1664


Ensure hardware command exists or update docs

The .github/copilot-instructions.md lists a hardware command, but no corresponding cobra definition (Use: "hardware") was found:

• Affected location:

  • .github/copilot-instructions.md (lines 26–43): the - hardware – System hardware information entry

Next steps:

  • Either implement a cobra command with Use: "hardware" (e.g. in cmd/hardware.go)
  • Or remove/update this line in the documentation to keep the list in sync

You can confirm with:

rg -n 'Use:\s*"hardware"' -S
🤖 Prompt for AI Agents
.github/copilot-instructions.md around lines 26 to 43: the docs list a
"hardware" CLI command but there is no corresponding cobra command
implementation; either add a cobra command with Use: "hardware" (e.g., create
cmd/hardware.go registering the command in root/cmd init) that implements the
described functionality or remove/update the "hardware" entry from the markdown
so docs and code stay in sync; run the suggested ripgrep check (rg -n
'Use:\s*"hardware"' -S) to verify presence after you add the command and ensure
the command is wired into the CLI root.

Comment on lines +45 to +49
## Development Environment
- **API Endpoint**: Configurable via `SUPERVISOR_ENDPOINT` environment variable
- **Authentication**: Uses API tokens via `SUPERVISOR_API_TOKEN` environment variable
- **Config File**: Optional config file support (default: `$HOME/.homeassistant.yaml`)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Add a brief security note for API tokens and verify default config path

  • Suggest warning to keep SUPERVISOR_API_TOKEN out of logs and shell history.
  • Verify the default config file path is correct.

Suggested doc tweak:

 - **Authentication**: Uses API tokens via `SUPERVISOR_API_TOKEN` environment variable
 - **Config File**: Optional config file support (default: `$HOME/.homeassistant.yaml`)
+  - Security: Avoid exposing `SUPERVISOR_API_TOKEN` in shell history or logs; prefer `.env` files or a secrets manager.

Verify config defaults:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n 'viper\.(SetConfig(Name|File)|AddConfigPath|SetDefault)' -A 2 -S || true
rg -n '\.homeassistant' -S || true

Length of output: 1273


Add security note for API token; default config path confirmed

Verified that the default config file path ($HOME/.homeassistant.yaml) is accurate (see README.md:20 and cmd/root.go:80,142–146). Please update .github/copilot-instructions.md (lines 45–49) with the following tweak:

- **Authentication**: Uses API tokens via `SUPERVISOR_API_TOKEN` environment variable
+ **Authentication**: Uses API tokens via `SUPERVISOR_API_TOKEN` environment variable  
  - Avoid exposing the token in shell history or logs; consider using `.env` files or a secrets manager.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
## Development Environment
- **API Endpoint**: Configurable via `SUPERVISOR_ENDPOINT` environment variable
- **Authentication**: Uses API tokens via `SUPERVISOR_API_TOKEN` environment variable
- **Config File**: Optional config file support (default: `$HOME/.homeassistant.yaml`)
## Development Environment
- **API Endpoint**: Configurable via `SUPERVISOR_ENDPOINT` environment variable
- **Authentication**: Uses API tokens via `SUPERVISOR_API_TOKEN` environment variable
- Avoid exposing the token in shell history or logs; consider using `.env` files or a secrets manager.
- **Config File**: Optional config file support (default: `$HOME/.homeassistant.yaml`)
🤖 Prompt for AI Agents
In .github/copilot-instructions.md around lines 45 to 49, update the
"Development Environment" block to add a short security note about the API token
and confirm the default config path: keep the existing entries for
SUPERVISOR_ENDPOINT, SUPERVISOR_API_TOKEN and the Config File path
($HOME/.homeassistant.yaml), and append one sentence advising that
SUPERVISOR_API_TOKEN should be treated as sensitive (set via environment
variables or secrets manager, do not commit to repo or store in plaintext) so
contributors know to protect the token.

Comment on lines +50 to +54
## Build Commands
- **Build**: `CGO_ENABLED=0 go build -ldflags="-s -w" -o "ha"`
- **Test**: `go test ./...`
- **Format**: `gofmt -s`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Formatting command should write changes; consider standard ‘go fmt’

“gofmt -s” only prints to stdout. Use -w, or just “go fmt ./...” for module-aware formatting.

-- **Format**: `gofmt -s`
+- **Format**: `gofmt -s -w .`  (or `go fmt ./...`)

Optionally verify if a Makefile or linting targets exist:


🏁 Script executed:

#!/bin/bash
set -euo pipefail
fd -a '^Makefile$' || true
rg -n 'golangci-lint|gofumpt|go fmt|gofmt' -S || true

Length of output: 163


Apply formatting changes with -w or use go fmt

The current command gofmt -s only prints diffs; it doesn’t modify files. Update it to write changes in-place.

• File: .github/copilot-instructions.md (around line 52)

- **Format**: `gofmt -s`
+ **Format**: `gofmt -s -w .`  (or `go fmt ./...`)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
## Build Commands
- **Build**: `CGO_ENABLED=0 go build -ldflags="-s -w" -o "ha"`
- **Test**: `go test ./...`
- **Format**: `gofmt -s`
## Build Commands
- **Build**: `CGO_ENABLED=0 go build -ldflags="-s -w" -o "ha"`
- **Test**: `go test ./...`
- **Format**: `gofmt -s -w .` (or `go fmt ./...`)
🤖 Prompt for AI Agents
In .github/copilot-instructions.md around lines 50 to 54, the Build Commands
section uses `gofmt -s` which only prints diffs and does not modify files;
change it to run formatting in-place by replacing that entry with either `gofmt
-s -w` or `go fmt ./...` so the command writes updates to files rather than just
displaying them.

@agners agners requested a review from sairon August 12, 2025 09:49
@agners agners merged commit d35c72e into master Aug 12, 2025
9 checks passed
@agners agners deleted the add-ai-instructions branch August 12, 2025 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants