-
Couldn't load subscription status.
- Fork 1
Add Claude Code configuration files #34
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
Open
echarrod
wants to merge
1
commit into
main
Choose a base branch
from
ed-add-claude-config
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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 |
|---|---|---|
|
|
@@ -4,3 +4,6 @@ | |
| # Local dev files | ||
| /go.work | ||
| /go.work.sum | ||
|
|
||
| # Claude Code local settings | ||
| .claude/settings.local.json | ||
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,119 @@ | ||
| # CLAUDE.md | ||
|
|
||
| This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||
|
|
||
| ## Project Overview | ||
|
|
||
| This is **danger-go**, a Go implementation of the popular Danger tool that runs automation rules during PR reviews. It's a wrapper around Danger JS that allows writing Dangerfiles in Go instead of JavaScript. | ||
|
|
||
| The project consists of: | ||
|
|
||
| - A Go library for writing Danger rules (`api.go`, `types.go`) | ||
| - A command-line tool (`cmd/danger-go/`) that wraps Danger JS | ||
| - Type definitions for various platforms (GitHub, GitLab) in `danger-js/` directory | ||
| - Platform-specific types in separate files (`types_*.go`) | ||
|
|
||
| ## Architecture | ||
|
|
||
| ### Core Components | ||
|
|
||
| 1. **API Layer** (`api.go`): Main public API with the `T` struct providing methods: | ||
| - `Message()` - Add informational messages | ||
| - `Warn()` - Add warnings that don't fail the build | ||
| - `Fail()` - Add failures that fail the build | ||
| - `Markdown()` - Add raw markdown to comments | ||
|
|
||
| 2. **Types** (`types.go`): Core data structures like `Results`, `Violation`, `GitHubResults` | ||
|
|
||
| 3. **Danger JS Bridge** (`danger-js/`): Integration layer that: | ||
| - Calls the `danger` (JS) binary to get DSL data | ||
| - Processes commands (`ci`, `local`, `pr`) by wrapping Danger JS | ||
| - Contains platform-specific type definitions | ||
|
|
||
| 4. **CLI Tool** (`cmd/danger-go/`): Command-line interface supporting: | ||
| - `ci` - Run on CI/CD | ||
| - `local` - Run locally for git hooks | ||
| - `pr` - Test against existing GitHub PR | ||
| - `runner` - Internal command for processing DSL via STDIN | ||
|
|
||
| ## Development Commands | ||
|
|
||
| ### Building and Testing | ||
|
|
||
| ```bash | ||
| # Run tests | ||
| go test -v ./... | ||
|
|
||
| # Build the CLI tool | ||
| go build -o danger-go cmd/danger-go/main.go | ||
|
|
||
| # Install the CLI tool globally | ||
| go install github.com/danger/golang/cmd/danger-go@latest | ||
| ``` | ||
|
|
||
| ### Running Danger Locally | ||
|
|
||
| ```bash | ||
| # Install dependencies first | ||
| npm install -g danger | ||
| go install github.com/danger/golang/cmd/danger-go@latest | ||
|
|
||
| # Run danger in CI mode (from build/ci directory) | ||
| cd build/ci && danger-go ci | ||
|
|
||
| # Run locally for testing | ||
| danger-go local | ||
|
|
||
| # Test against a specific PR | ||
| danger-go pr https://github.com/owner/repo/pull/123 | ||
| ``` | ||
|
|
||
| ### Development Workflow | ||
|
|
||
| The project follows standard Go conventions: | ||
|
|
||
| - Use `go fmt` for formatting | ||
| - Run `go vet` for static analysis | ||
| - Follow [Effective Go](https://go.dev/doc/effective_go) guidelines | ||
| - Write table-driven tests where appropriate | ||
| - Use conventional commit messages | ||
|
|
||
| ## Dangerfile Structure | ||
|
|
||
| Dangerfiles are Go programs that must: | ||
|
|
||
| 1. Be in a separate directory (e.g., `build/ci/`) | ||
| 2. Have a `Run(d *danger.T, pr danger.DSL)` function | ||
| 3. Import `github.com/danger/golang` | ||
| 4. Have their own go.mod file | ||
|
|
||
| Example Dangerfile setup: | ||
|
|
||
| ```bash | ||
| mkdir build/ci | ||
| cd build/ci | ||
| go mod init dangerfile | ||
| go get github.com/danger/golang | ||
| ``` | ||
|
|
||
| ## Key Dependencies | ||
|
|
||
| - **Go 1.24+** required | ||
| - **Danger JS** must be installed globally (`npm install -g danger`) | ||
| - **github.com/stretchr/testify** for testing | ||
|
|
||
| ## CI/CD Integration | ||
|
|
||
| The project uses GitHub Actions (`.github/workflows/test.yml`) which: | ||
|
|
||
| - Installs Go 1.24+ | ||
| - Installs Node.js and Danger JS | ||
| - Runs both Go tests and danger-go CI checks | ||
| - Requires `GITHUB_TOKEN` for GitHub API access | ||
|
|
||
| ## Testing | ||
|
|
||
| - Use `go test -v ./...` to run all tests | ||
| - Tests are in `*_test.go` files | ||
| - Internal tests in `api_internal_test.go` test unexported functions | ||
| - Follow table-driven test patterns where applicable | ||
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.
Uh oh!
There was an error while loading. Please reload this page.