Skip to content

Commit 8d8e028

Browse files
fredbiclaude
andauthored
doc: add portable agentic instructions (#136)
Add contributions rule, AGENTS.md symlink, fix mono-repo description in CLAUDE.md, add hooks/ to .claude/.gitignore. Signed-off-by: Frederic BIDON <[email protected]> Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
1 parent c94d185 commit 8d8e028

File tree

7 files changed

+98
-3
lines changed

7 files changed

+98
-3
lines changed

.claude/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ plans/
22
skills/
33
commands/
44
agents/
5+
hooks/

.claude/CLAUDE.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ This repository provides shared, reusable GitHub Actions workflows for the go-op
1010

1111
When working with GitHub Actions workflows in this repository, refer to:
1212

13-
📖 **`.claude/rules/github-workflows-conventions.md`** (auto-loaded for workflow files):
13+
**`.claude/rules/github-workflows-conventions.md`** (auto-loaded for workflow files):
1414
- YAML formatting and style conventions (expression spacing, step arrays, conditionals)
1515
- Security rules (SHA pinning, permissions, secret exposure)
1616
- Common gotchas (boolean inputs, description fields)
1717

18-
📖 **`.claude/skills/github-actions.md`** for:
18+
**`.claude/skills/github-actions.md`** for:
1919
- Behavioral patterns (race condition handling, optimistic execution)
2020
- Workflow recipes (bot-credentials, wait-pending-jobs, auto-merge)
2121
- Action definition best practices and documentation standards
@@ -137,11 +137,12 @@ The `auto-merge.yml` workflow handles two bot types:
137137
- `.golangci.yml` - Linter configuration (many linters disabled to match go-openapi style)
138138
- `.cliff.toml` - Release notes generation configuration
139139
- `.github/dependabot.yaml` - Dependency update configuration
140+
- `go.work` - Go workspace tying root and `sample-monorepo` modules together
140141
- `go.mod` - Requires Go 1.24.0
141142

142143
## Important Notes
143144

144145
- All workflow action versions are pinned to commit SHAs for security
145146
- Permissions are explicitly granted at job level to follow least-privilege principle
146-
- This repo itself uses minimal Go code (just sample tests); it's primarily YAML workflows
147+
- This repo is a mono-repo (`go.work`) with a `sample-monorepo` submodule used to exercise the CI workflows against a multi-module layout; it's primarily YAML workflows
147148
- The `local-*` workflows serve as both tests and documentation of proper usage

.claude/rules/contributions.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
paths:
3+
- "**/*"
4+
---
5+
6+
# Contribution rules (go-openapi)
7+
8+
Read `.github/CONTRIBUTING.md` before opening a pull request.
9+
10+
## Commit hygiene
11+
12+
- Every commit **must** be DCO signed-off (`git commit -s`) with a real email address.
13+
PGP-signed commits are appreciated but not required.
14+
- Agents may be listed as co-authors (`Co-Authored-By:`) but the commit **author must be the human sponsor**.
15+
We do not accept commits solely authored by bots or agents.
16+
- Squash commits into logical units of work before requesting review (`git rebase -i`).
17+
18+
## Linting
19+
20+
Before pushing, verify your changes pass linting against the base branch:
21+
22+
```sh
23+
golangci-lint run --new-from-rev master
24+
```
25+
26+
Install the latest version if you don't have it:
27+
28+
```sh
29+
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
30+
```
31+
32+
## Problem statement
33+
34+
- Clearly describe the problem the PR solves, or reference an existing issue.
35+
- PR descriptions must not be vague ("fix bug", "improve code") — explain *what* was wrong and *why* the change is correct.
36+
37+
## Tests are mandatory
38+
39+
- Every bug fix or feature **must** include tests that demonstrate the problem and verify the fix.
40+
- The only exceptions are documentation changes and typo fixes.
41+
- Aim for at least 80% coverage of your patch.
42+
- Run the full test suite before submitting:
43+
44+
For mono-repos:
45+
```sh
46+
go test work ./...
47+
```
48+
49+
For single module repos:
50+
```sh
51+
go test ./...
52+
```

.claude/rules/github-workflows-conventions.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,3 +265,33 @@ description: |
265265
**Rule**: Use `type: string` with values `'true'` or `'false'` for all boolean-like workflow inputs.
266266

267267
**Note**: Step outputs and bash variables are always strings, so `x == 'true'` works fine for those.
268+
269+
### YAML fold scalars in action inputs
270+
271+
**NEVER** use `>` or `>-` (fold scalars) for `with:` input values:
272+
273+
> The YAML spec says fold scalars replace newlines with spaces, but the GitHub Actions runner
274+
> does not reliably honor this for action inputs. The action receives the literal multi-line string
275+
> instead of a single folded line, which breaks flag parsing.
276+
277+
```yaml
278+
# ❌ BROKEN - Fold scalar, args received with embedded newlines
279+
- uses: goreleaser/goreleaser-action@...
280+
with:
281+
args: >-
282+
release
283+
--clean
284+
--release-notes /tmp/notes.md
285+
286+
# ✅ CORRECT - Single line
287+
- uses: goreleaser/goreleaser-action@...
288+
with:
289+
args: release --clean --release-notes /tmp/notes.md
290+
291+
# ✅ CORRECT - Literal block scalar (|) is fine for run: scripts
292+
- run: |
293+
echo "line 1"
294+
echo "line 2"
295+
```
296+
297+
**Rule**: Use single-line strings for `with:` inputs. Only use `|` (literal block scalar) for `run:` scripts where multi-line is intentional.

.github/copilot-instructions.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,10 @@ When editing workflow files, follow the conventions documented in `.github/copil
1717
- **Shared workflows** (`.github/workflows/*.yml`): called by other go-openapi repos
1818
- **Local test workflows** (`local-*.yml`): test the shared workflows within this repo
1919
- New reusable actions belong in `go-openapi/gh-actions`, not here
20+
21+
## Contributions
22+
23+
- Every commit must be DCO signed-off (`git commit -s`)
24+
- Agents may be co-authors but the commit author must be a human
25+
- PRs must clearly describe the problem and include tests
26+
- Run `golangci-lint run --new-from-rev master` before pushing

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ profile.cov
2727
# env file
2828
.env
2929

30+
# MCP configuration
31+
.mcp.json
32+
3033
# Editor/IDE
3134
# .idea/
3235
# .vscode/

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.github/copilot-instructions.md

0 commit comments

Comments
 (0)