Skip to content

Commit 839f84e

Browse files
fredbiclaude
andauthored
doc: add portable agentic instructions (#86)
* doc: add portable agentic instructions Add copilot-instructions.md, AGENTS.md (symlink), .github/copilot symlink to .claude/rules, contributions and workflows rules. Update CLAUDE.md with full package documentation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Frederic BIDON <fredbi@yahoo.com> * doc: include previously ignored rule files Add linting.md and testing.md rules that were hidden by the old .gitignore pattern. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Frederic BIDON <fredbi@yahoo.com> --------- Signed-off-by: Frederic BIDON <fredbi@yahoo.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5f35b4b commit 839f84e

File tree

11 files changed

+535
-1
lines changed

11 files changed

+535
-1
lines changed

.claude/.gitignore

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

.claude/CLAUDE.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
Go implementation of [JSON Reference](https://datatracker.ietf.org/doc/html/draft-pbryan-zyp-json-ref-03)
8+
(RFC 3986-based URI references with JSON Pointer fragments). JSON References are used
9+
extensively in OpenAPI and JSON Schema specifications to express `$ref` links between
10+
documents and within a single document.
11+
12+
The `Ref` type parses a reference string into its URL and JSON Pointer components, classifies
13+
it (full URL, path-only, fragment-only, file scheme), and supports inheritance (resolving a
14+
child reference against a parent).
15+
16+
See [docs/MAINTAINERS.md](../docs/MAINTAINERS.md) for CI/CD, release process, and repo structure details.
17+
18+
### Package layout (single package)
19+
20+
| File | Contents |
21+
|------|----------|
22+
| `reference.go` | `Ref` type, constructors (`New`, `MustCreateRef`), accessors (`GetURL`, `GetPointer`, `String`), classification (`IsRoot`, `IsCanonical`), and `Inherits` for parent-child resolution |
23+
| `internal/normalize_url.go` | URL normalization (lowercase scheme/host, remove default ports, deduplicate slashes) — replaces the deprecated `purell` library |
24+
25+
### Key API
26+
27+
- `Ref` — the core type representing a parsed JSON Reference
28+
- `New(string) (Ref, error)` — parse a JSON Reference string
29+
- `MustCreateRef(string) Ref` — parse or panic
30+
- `(*Ref).GetURL() *url.URL` — the underlying URL
31+
- `(*Ref).GetPointer() *jsonpointer.Pointer` — the JSON Pointer fragment
32+
- `(*Ref).Inherits(child Ref) (*Ref, error)` — resolve a child reference against this parent
33+
- `(*Ref).IsRoot() bool` — true if this is a root document reference
34+
- `(*Ref).IsCanonical() bool` — true if the reference starts with `http(s)://` or `file://`
35+
36+
### Dependencies
37+
38+
- `github.com/go-openapi/jsonpointer` — JSON Pointer (RFC 6901) implementation
39+
- `github.com/go-openapi/testify/v2` — test-only assertions (zero-dep testify fork)
40+
41+
### Notable design decisions
42+
43+
- **Replaced `purell` with internal normalization** — the `internal/normalize_url.go` file
44+
replaces the unmaintained `purell` library. It performs only the safe normalizations that
45+
were previously used: lowercase scheme/host, remove default HTTP(S) ports, and deduplicate
46+
path slashes.
47+
- **Classification flags on `Ref`** — rather than re-parsing on each query, the `parse` method
48+
sets boolean flags (`HasFullURL`, `HasURLPathOnly`, `HasFragmentOnly`, `HasFileScheme`,
49+
`HasFullFilePath`) once at construction time.
50+
- **JSON Pointer errors are silently ignored** — if the URL fragment is not a valid JSON Pointer,
51+
the pointer is left as zero-value. This allows the type to represent any URI reference, not
52+
just those with valid JSON Pointer fragments.

.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+
```

0 commit comments

Comments
 (0)