-
Notifications
You must be signed in to change notification settings - Fork 3
Add CLAUDE.md for Claude Code guidance #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| # CLAUDE.md | ||
|
|
||
| This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||
|
|
||
| ## Project Overview | ||
|
|
||
| toolhive-core is a shared Go library providing stable, well-tested utilities for the ToolHive ecosystem. It serves as a common dependency for toolhive, dockyard, toolhive-registry, and toolhive-registry-server projects. | ||
|
|
||
| ## Build and Development Commands | ||
|
|
||
| This project uses [Task](https://taskfile.dev/) for automation: | ||
|
|
||
| ```bash | ||
| task # Run all checks (lint + test) | ||
| task lint # Run golangci-lint and go vet | ||
| task test # Run tests with race detection | ||
| ``` | ||
|
|
||
| Run a single test: | ||
| ```bash | ||
| go test -race -run TestFunctionName ./path/to/package | ||
| ``` | ||
|
|
||
| Other commands: | ||
| ```bash | ||
| task lint-fix # Auto-fix linting issues | ||
| task test-coverage # Run tests with coverage report | ||
| task gen # Generate mocks using mockgen | ||
| task tidy # go mod tidy && go mod verify | ||
| task license-check # Verify SPDX license headers | ||
| task license-fix # Add missing license headers | ||
| ``` | ||
|
|
||
| ## Development Workflow | ||
|
|
||
| 1. Implement changes with tests (≥70% coverage) | ||
| 2. Run `task` to verify lint + tests pass | ||
|
aponcedeleonch marked this conversation as resolved.
|
||
| 3. If adding mocks: add `//go:generate` directive, run `task gen` | ||
| 4. Run `task license-check` before committing | ||
|
|
||
| ## Boundaries | ||
|
|
||
| ### Never | ||
| - Remove or skip existing tests | ||
| - Change exported interface signatures without discussion | ||
| - Modify `go.mod` dependencies without being asked | ||
|
|
||
| ### Ask First | ||
| - Adding new packages (need to consider stability track) | ||
| - Adding new dependencies | ||
| - Changes to error codes in `httperr` | ||
|
|
||
| ### Always | ||
| - Run `task` before considering work complete | ||
| - Include table-driven tests for new functions | ||
| - Use interface-based design for new packages (see `env.Reader` pattern) | ||
|
|
||
| ## Architecture | ||
|
|
||
| ### Package Design Principles | ||
|
|
||
| 1. **Interface-based design** - Public APIs expose interfaces for testability and mock generation | ||
| 2. **Dependency injection** - Enables mocking (see `env.Reader` interface pattern) | ||
| 3. **Error wrapping** - Uses Go 1.13+ error wrapping compatible with `errors.Is()` and `errors.As()` | ||
| 4. **Security-first validation** - All validators check for injection attacks (CRLF, control chars) and enforce length limits | ||
|
|
||
| ### Current Packages | ||
|
|
||
| | Package | Purpose | | ||
| |---------|---------| | ||
| | `env` | Environment variable abstraction with `Reader` interface for testable code | | ||
| | `httperr` | Wrap errors with HTTP status codes; use `WithCode()`, `Code()`, `New()` | | ||
| | `validation/http` | RFC 7230/8707 compliant HTTP header and URI validation | | ||
| | `validation/group` | Group name validation (lowercase alphanumeric, underscore, dash, space) | | ||
|
|
||
| ### Mock Generation | ||
|
|
||
| Mocks are generated using `go.uber.org/mock`. Add `//go:generate` directives in source files, then run `task gen`. | ||
|
|
||
| ## Code Quality Notes | ||
|
|
||
| - **Test coverage**: ≥70% required for package graduation | ||
| - **License headers**: Run `task license-check` before committing to verify SPDX headers | ||
|
|
||
| ## Stability Guarantees | ||
|
|
||
| Packages follow graduation tracks: | ||
| - **Stable**: Production-ready, semantic versioning applies | ||
| - **Beta**: API may change with deprecation notices | ||
| - **Alpha**: Experimental, breaking changes possible | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Probably worth deleting this. The agent most probably just receives the contents of the file in the system prompt for context, i.e. it doesn't even has a perception that this came from a file