Imported from hedhyw/gherkingen (
AGENTS.md). Install upstream withnpx skills add hedhyw/gherkingen. Copyright stays with the author.
AGENTS.md
Guidance for AI coding agents working in this repository.
What this project is
gherkingen is a command-line generator of Behaviour Driven Development (BDD)
test boilerplate for Go. It parses a Cucumber/Gherkin *.feature file and
renders a Go test skeleton (table-driven, parallel by default) through a
text/template. Output is customizable: any Go testing framework, or even
non-Go languages, can be targeted by supplying a custom template with
-format raw. Module path: github.com/hedhyw/gherkingen/v4 (binary in
cmd/gherkingen).
CLI usage
gherkingen [flags] FEATURE_FILE
Key flags (see internal/app/app.go for the authoritative list):
-format— output format:autodetect(default),json,go,raw.-template— template file;@/prefix refers to embedded templates (default@/std.simple.v1.go.tmpl).-package— generated package name (defaultgenerated_test).-language— natural language of the feature (defaulten); may also be inferred from a<name>.<lang>.featurefile name.-permanent-ids— deterministic UUIDs, same input gives same output.-disable-go-parallel— do not emitt.Parallel().-list/-languages/-version/-help— informational.
There is no public Go API: all packages live under internal/.
Repository layout
cmd/gherkingen/main.go— entry point, callsinternal/app.Run.internal/app— CLI wiring: flag parsing, template resolution (templates.go), language handling,app.feature/app_test.goBDD tests.internal/generator— renders the parsed document:golang.go(Go templates),json.go,raw.go.internal/generator/examples— example*.featureinputs and their GENERATED outputs insimple/andsimpleparallel/(see below).internal/model— data model passed to templates (TemplateData, Gherkin document types, format enums).internal/assets— embedded templates (//go:embed *.tmpl), currentlystd.simple.v1.go.tmpl.internal/docplugin— plugins that inject extra data into the document before rendering;gopluginadds Go types/aliases,multiplugincombines plugins.scripts/examples.sh— regenerates the example outputs.assets/— README images only.
Build, test, lint
make build # builds ./bin/gherkingen with version from git describe
make test # go test with coverage profile (coverage.out)
make lint # golangci-lint (version pinned via GOLANG_CI_LINT_VER in Makefile, config .golangci.json)
make generate # regenerate internal/generator/examples outputs
make check.generate # fails if generated examples are stale
CI (.github/workflows/check.yml) runs build, lint, check.generate, and
test on every PR and push to main.
Generated files — do not edit by hand
gherkingen is itself a code generator and dogfoods its output:
internal/generator/examples/simple/*_test.goandinternal/generator/examples/simpleparallel/*_test.goare generated from the sibling*.featurefiles byscripts/examples.sh. After changing templates, the generator, or any example feature, runmake generateand commit the result; CI enforces this viamake check.generate.- Everything else (including
internal/assets/*.go.tmpl) is hand-written source.
Adding a new template
- Create
internal/assets/<name>.go.tmpl(Gotext/template; the root object isinternal/model.TemplateData). - Register it in
TestOpenTemplateininternal/assets/assets_test.go. - Run
make lint check.generate test.
Conventions
- PR titles must follow Conventional Commits (enforced by the
check-pr-semanticworkflow). - Errors use
github.com/hedhyw/semerr; tests usestretchr/testify. - Dependencies are managed with Go modules only (no
vendor/directory); rungo mod tidyafter changinggo.mod. - Releases are tag-driven (
.goreleaser.yml, Docker imagehedhyw/gherkingen).