Skip to content

Commit dfdfa97

Browse files
dmcilvaneyCopilot
andauthored
docs: add description fields and coding guidelines to instruction files (#79)
Add description frontmatter to docs and go instruction files for better agent discoverability. Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 8fef345 commit dfdfa97

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

.github/instructions/docs.instructions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
applyTo: "**/*"
3+
description: "Documentation requirements for user-facing features. Always check this file when working on features that the user may interact with."
34
---
45

56
# Documentation Requirements

.github/instructions/go.instructions.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
applyTo: "**/*.go"
3+
description: "Instructions for working on the azldev Go codebase. IMPORTANT: Always read these instructions when reading or editing Go code in this repository."
34
---
45

56
# Guidelines for Copilot
@@ -44,6 +45,14 @@ applyTo: "**/*.go"
4445
- Ensure code passes golangci-lint checks
4546
- Use `github.com/microsoft/azure-linux-dev-tools/internal/utils/fileperms` instead of re-defining file permission constants
4647
- Use `github.com/microsoft/azure-linux-dev-tools/internal/utils/fileutils` for file operations like `Exists`, `ReadFile`, `WriteFile`, not "github.com/spf13/afero" directly.
48+
- Avoid directly using os package functions for file operations; use the fileutils package instead.
49+
50+
### External Command Execution
51+
52+
- **NEVER** use `exec.LookPath` to check for external tools. Use `ctx.CommandInSearchPath("toolname")` or `env.CommandInSearchPath("toolname")` instead — these delegate to the underlying command factory and integrate with `testctx` for stubbing in tests (for example via `testEnv.CmdFactory.RegisterCommandInSearchPath(...)`).
53+
- Use `exec.CommandContext(ctx, "toolname", args...)` with the binary name (not an absolute path) after the `CommandInSearchPath` check. PATH resolution happens at exec time.
54+
- Always wrap with `ctx.Command(rawCmd)` or `env.Command(rawCmd)` and use `cmd.RunAndGetOutput(ctx)` or `cmd.Run(ctx)` for consistent event tracking and dry-run support.
55+
- Capture stderr separately via `rawCmd.Stderr = &stderr` (set BEFORE `ctx.Command()` / `env.Command()`) for use in error messages.
4756

4857
### Return values
4958

@@ -83,6 +92,10 @@ applyTo: "**/*.go"
8392
}
8493
```
8594

95+
### Cmdline Returns
96+
97+
CLI commands should return meaningful structured results. azldev has output formatting helpers to facilitate this (for example, `RunFunc*` wrappers handle formatting, so callers typically should not call `reflectable.FormatValue` directly).
98+
8699
## Quality Standards
87100

88101
- Make minimal, focused changes to achieve the required functionality
@@ -91,3 +104,11 @@ applyTo: "**/*.go"
91104
- Organize imports according to Go best practices
92105
- Linting: Prefer fixing issues over `//nolint` comments. Use targeted `//nolint:<linter>` if absolutely required
93106
- Testing: Table-driven tests preferred. Use `scenario/internal/cmdtest` helpers
107+
108+
### Component Command Testing
109+
110+
New component subcommands (`internal/app/azldev/cmds/component/`) require:
111+
- **Command wiring test** (`*_test.go`, external `package component_test`): verify `NewXxxCmd()` returns a valid command with correct `Use`, `RunE`, and expected flags/defaults.
112+
- **No-match test**: call `cmd.ExecuteContext(testEnv.Env)` with a nonexistent component to verify error handling.
113+
- **Helper unit tests** (`*_test.go`, same-package `package component`): test unexported helper functions (e.g., `findSpecFile`, `cleanupStaleRenders`) using `afero.NewMemMapFs`; where needed, follow the existing `//nolint:testpackage` pattern used in this repo.
114+
- **Snapshot update**: if the command changes the schema or CLI docs, run `mage scenarioUpdate` to update snapshots.

0 commit comments

Comments
 (0)