Skip to content

Commit f34dcc6

Browse files
khrmclaude
authored andcommitted
Add agentic workflows context files
Agent configuration goes to generic files: AGENTS.md and .agents/. CLAUDE.md is a symlink to AGENTS.md so all agents share the same context. Includes: - AGENTS.md: project overview, build/test commands, architecture, pattern references - .agents/guidelines.md: generic LLM coding guidelines - .claude/skills: symlink to .agents/skills for repo-local skills - .pre-commit-config.yaml: pre-commit hooks for Go formatting and linting - docs/adr/: architecture decision records linking to TEPs and capturing core invariants - .gitignore: add coverage files, editor swap files, agentready artifacts AgentReady assessment: 77.6/100 (Gold, up from 58.4/100 Bronze) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent bf95a60 commit f34dcc6

10 files changed

Lines changed: 360 additions & 0 deletions

File tree

.agents/guidelines.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Coding Guidelines
2+
3+
Behavioral guidelines to reduce common LLM coding mistakes. Merge with project-specific instructions as needed.
4+
5+
**Tradeoff:** These guidelines bias toward caution over speed. For trivial tasks, use judgment.
6+
7+
## 1. Think Before Coding
8+
9+
**Don't assume. Don't hide confusion. Surface tradeoffs.**
10+
11+
Before implementing:
12+
- State your assumptions explicitly. If uncertain, ask.
13+
- If multiple interpretations exist, present them - don't pick silently.
14+
- If a simpler approach exists, say so. Push back when warranted.
15+
- If something is unclear, stop. Name what's confusing. Ask.
16+
- If you disagree with a specific decision from the user, explain why. Ask the user to confirm their decision.
17+
18+
## 2. Simplicity First
19+
20+
**Minimum code that solves the problem. Nothing speculative.**
21+
22+
- No features beyond what was asked.
23+
- No abstractions for single-use code.
24+
- No "flexibility" or "configurability" that wasn't requested.
25+
- No error handling for impossible scenarios.
26+
- If you write 200 lines and it could be 50, rewrite it.
27+
28+
Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes, simplify.
29+
30+
## 3. Surgical Changes
31+
32+
**Touch only what you must. Clean up only your own mess.**
33+
34+
When editing existing code:
35+
- Don't "improve" adjacent code, comments, typos or formatting.
36+
- Don't refactor things that aren't broken.
37+
- Match existing style, even if you'd do it differently.
38+
- If you notice unrelated dead code, mention it - don't delete it.
39+
40+
When your changes create orphans:
41+
- Remove imports/variables/functions that YOUR changes made unused.
42+
- Don't remove pre-existing dead code unless asked.
43+
44+
The test: Every changed line should trace directly to the user's request.
45+
46+
## 4. Goal-Driven Execution
47+
48+
**Define success criteria. Loop until verified.**
49+
50+
Transform tasks into verifiable goals:
51+
- "Add validation" → "Write tests for invalid inputs, then make them pass"
52+
- "Fix the bug" → "Write a test that reproduces it, then make it pass"
53+
- "Refactor X" → "Ensure tests pass before and after"
54+
55+
For multi-step tasks, state a brief plan:
56+
```
57+
1. [Step] → verify: [check]
58+
2. [Step] → verify: [check]
59+
3. [Step] → verify: [check]
60+
```
61+
62+
Strong success criteria let you loop independently. Weak criteria ("make it work") require constant clarification.
63+
64+
---
65+
66+
**These guidelines are working if:** fewer unnecessary changes in diffs, fewer rewrites due to overcomplication, and clarifying questions come before implementation rather than after mistakes.

.agents/skills/.gitkeep

Whitespace-only changes.

.claude/skills

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../.agents/skills

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,19 @@ cmd/*/kodata/source.tar.gz
5151
# Temporary GOPATH used during code gen if user's Tekton checkout is
5252
# not already in GOPATH.
5353
.gopath
54+
55+
# AgentReady assessment artifacts
56+
.agentready/
57+
.agentready-config.yaml
58+
59+
# Coverage and test output
60+
cover.out
61+
coverage.txt
62+
coverage_raw.out
63+
64+
# Editor swap files
65+
*.swo
66+
*.swp
67+
68+
# macOS
69+
.DS_Store

.pre-commit-config.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.5.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-added-large-files
9+
- id: check-merge-conflict
10+
- id: check-toml
11+
- id: check-json
12+
- id: detect-private-key
13+
14+
- repo: https://github.com/dnephin/pre-commit-golang
15+
rev: v0.5.1
16+
hooks:
17+
- id: go-fmt
18+
- id: go-imports
19+
- id: go-vet
20+
- id: go-unit-tests
21+
22+
- repo: https://github.com/golangci/golangci-lint
23+
rev: v2.8.0
24+
hooks:
25+
- id: golangci-lint

AGENTS.md

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# Tekton Triggers
2+
3+
Event-driven CI/CD controller for Kubernetes. Listens for events (GitHub webhooks, etc.),
4+
maps them to Tekton PipelineRuns/TaskRuns via TriggerBindings and TriggerTemplates, and
5+
creates Kubernetes resources through EventListeners.
6+
7+
**Behavioral guidelines**: See [.agents/guidelines.md](./.agents/guidelines.md) for generic coding principles.
8+
9+
---
10+
11+
## Build & Test Commands
12+
13+
```bash
14+
# Build all binaries
15+
make all
16+
17+
# Build specific component
18+
make bin/controller
19+
make bin/eventlistenersink
20+
make bin/interceptors
21+
make bin/webhook
22+
make bin/tkn-triggers
23+
24+
# Unit tests — no cluster required
25+
make test-unit
26+
27+
# End-to-end tests — requires a running cluster
28+
make test-e2e
29+
30+
# YAML tests
31+
make test-yamls
32+
33+
# Format code — required before PR submission
34+
make fmt
35+
36+
# Lint — must pass before every PR
37+
make golangci-lint
38+
39+
# Code generation — required after modifying types or CRD schemas
40+
./hack/update-codegen.sh
41+
```
42+
43+
---
44+
45+
## Single-File Verification
46+
47+
```bash
48+
# Lint a single Go file
49+
golangci-lint run path/to/file.go
50+
51+
# Type-check using staticcheck
52+
staticcheck ./path/to/pkg/...
53+
54+
# Format a single file in place
55+
gofmt -w path/to/file.go
56+
57+
# Vet the package containing the file
58+
go vet ./path/to/pkg/...
59+
```
60+
61+
---
62+
63+
## Key Conventions
64+
65+
1. **Dependencies are vendored.** All Go dependencies live in `vendor/`. Review agents
66+
should ignore the `vendor/` directory — it contains third-party code.
67+
68+
2. **Use structured logging.** Import `knative.dev/pkg/logging` and use context-aware
69+
loggers. Never use `fmt.Printf` or `log.Print` in production code.
70+
71+
3. **CRD types live in `pkg/apis/`.** After modifying any type definition, run
72+
`./hack/update-codegen.sh` to regenerate deepcopy, client, and informer code.
73+
74+
4. **Interceptors are the request/response processing layer.** Core interceptors
75+
(CEL, GitHub, GitLab, Bitbucket, Slack) live in `pkg/interceptors/` and run as a
76+
dedicated HTTPS service (port 8443). Custom interceptors are registered via the
77+
`ClusterInterceptor` CRD and called by the sink over HTTP(S). The `pkg/interceptors/webhook/`
78+
package handles the deprecated `Interceptor.Webhook` field for calling arbitrary
79+
external URLs directly from the sink — distinct from `ClusterInterceptor`.
80+
81+
5. **Test coverage is enforced.** PRs adding functionality must include tests.
82+
E2E tests are tagged and require a cluster — unit tests should not.
83+
84+
6. **Config lives in `config/`.** Kubernetes manifests (CRDs, RBAC, deployments)
85+
are generated/managed there. Do not hand-edit generated CRD YAML.
86+
87+
---
88+
89+
## Architecture
90+
91+
**Controller** (`cmd/controller`, `pkg/reconciler/`): Reconciles EventListener,
92+
TriggerBinding, TriggerTemplate, ClusterTriggerBinding, ClusterInterceptor CRDs.
93+
Uses Knative's controller framework.
94+
95+
**EventListener Sink** (`cmd/eventlistenersink`, `pkg/sink/`): HTTP server
96+
that receives events and processes them through trigger bindings, templates, and
97+
interceptors to create Kubernetes resources.
98+
99+
**Interceptors** (`cmd/interceptors`, `pkg/interceptors/`): HTTPS service (port 8443)
100+
handling core interceptors (CEL, GitHub, GitLab, Bitbucket, Slack). The sink calls interceptors
101+
via HTTP POST. ClusterInterceptors can extend this for custom logic.
102+
103+
**Webhook** (`cmd/webhook`): Kubernetes admission webhook for validating and
104+
defaulting CRD resources.
105+
106+
**tkn-triggers CLI** (`cmd/tkn-triggers`): CLI plugin for `tkn` to interact
107+
with Triggers resources.
108+
109+
**Utility CLIs** (`cmd/binding-eval`, `cmd/cel-eval`, `cmd/triggerrun`): Developer
110+
tools for evaluating bindings, CEL expressions, and trigger processing locally.
111+
112+
---
113+
114+
## Pattern References for Common Changes
115+
116+
- **New interceptor type**: Follow `pkg/interceptors/cel/` as the reference implementation
117+
- **New reconciler**: Follow `pkg/reconciler/eventlistener/` for structure and patterns
118+
- **New CRD type**: Add to `pkg/apis/triggers/`, update `./hack/update-codegen.sh`
119+
- **Sink event processing**: See `pkg/sink/sink.go` for the main event handling path
120+
- **E2E tests**: Follow examples in `test/eventlistener_test.go`
121+
- **CEL expressions**: See `pkg/interceptors/cel/` and `docs/cel_expressions.md`
122+
123+
---
124+
125+
## PR Conventions
126+
127+
- Pull requests must follow the repository PR template in `.github/pull_request_template.md`.
128+
- Run `make fmt` before submitting for review.
129+
- `make golangci-lint` must pass with zero issues.
130+
- Tests required for any functionality changes.
131+
- Follow [Tekton commit message standards](https://github.com/tektoncd/community/blob/main/standards.md#commits).
132+
- Add `/kind <type>` label (bug, feature, cleanup, etc.).
133+
- Update release notes block if user-facing changes.
134+
- Run `./hack/update-codegen.sh` after modifying CRD types.
135+
- Ignore `vendor/` directory in reviews — contains vendored dependencies only.
136+
137+
---
138+
139+
## Skills
140+
141+
None configured yet. Repo-local skills can be added to `.agents/skills/`.

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AGENTS.md
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# ADR-0001: Event-Driven Architecture and Component Responsibilities
2+
3+
**Status:** Accepted
4+
**Date:** 2024-01-01
5+
6+
## Context
7+
8+
Tekton Triggers needs to bridge external events (webhooks, CloudEvents) to Tekton
9+
PipelineRun/TaskRun creation in a Kubernetes-native way.
10+
11+
## Decision
12+
13+
Triggers is structured around four distinct responsibilities with strict separation:
14+
15+
1. **EventListener** — receives and routes incoming HTTP events
16+
2. **Interceptors** — validate and transform event payloads before trigger evaluation
17+
3. **TriggerBinding** — extracts parameters from event payloads
18+
4. **TriggerTemplate** — defines the Kubernetes resources to create
19+
20+
## Architectural Invariants
21+
22+
- **Only the EventListener sink creates Kubernetes resources.** Interceptors, bindings,
23+
and templates are pure transformation steps with no side effects.
24+
- **Interceptors are stateless.** Each interceptor processes a request independently.
25+
No interceptor stores state between requests.
26+
- **TriggerBindings are read-only.** They extract data from the event payload but never
27+
mutate it.
28+
- **Tekton Pipelines must be installed before Triggers.** Triggers depends on the
29+
Pipeline CRDs (PipelineRun, TaskRun) being present in the cluster.
30+
- **EventListener is the only network ingress point.** All external events enter the
31+
system exclusively through the EventListener HTTP endpoint.
32+
33+
## Preconditions
34+
35+
- A Kubernetes cluster with RBAC enabled
36+
- Tekton Pipelines installed and healthy
37+
- For TLS: valid certificates configured on the EventListener
38+
39+
## Consequences
40+
41+
- Interceptors can be developed and tested independently without a cluster
42+
- The sink is the single point of Kubernetes API interaction, simplifying RBAC requirements
43+
- Core and custom interceptors are both called via HTTP(S) from the sink; core interceptors
44+
run as a separate in-cluster service (not in-process with the sink)
45+
- Custom interceptors can be implemented in any language that can serve HTTP(S)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# ADR-0002: Interceptor Communication via HTTP(S) Webhook
2+
3+
**Status:** Accepted
4+
**Date:** 2024-01-01
5+
**TEPs:** [TEP-0026](https://github.com/tektoncd/community/blob/main/teps/0026-interceptor-plugins.md)
6+
7+
## Context
8+
9+
Triggers needs to support both built-in interceptors (CEL, GitHub, GitLab, Bitbucket, Slack)
10+
and user-defined custom interceptors, while keeping the extension model language-agnostic.
11+
12+
## Decision
13+
14+
All interceptors — core and custom — are invoked by the sink via **HTTP(S) POST** using
15+
a JSON `InterceptorRequest`/`InterceptorResponse` contract:
16+
17+
- **Core interceptors** (CEL, GitHub, GitLab, Bitbucket, Slack) run as a dedicated
18+
in-cluster HTTPS service (`cmd/interceptors`, port 8443) separate from the sink.
19+
- **Custom interceptors** are deployed as separate services and registered via the
20+
`ClusterInterceptor` CRD; the sink calls them at the configured HTTP(S) URL.
21+
22+
## Architectural Invariants
23+
24+
- The `InterceptorRequest`/`InterceptorResponse` JSON contract over HTTP(S) is the
25+
canonical interface. Any interceptor — core or custom — must implement this contract.
26+
- Interceptors are called sequentially in the order defined in the `EventListener` spec.
27+
A failed interceptor short-circuits the chain; subsequent interceptors are not called.
28+
- An interceptor that returns `continue: false` stops processing without creating
29+
any Kubernetes resources.
30+
- Core interceptors share a single process and must not share mutable state between
31+
requests.
32+
33+
## Preconditions
34+
35+
- Core interceptors service must be reachable from the sink within the cluster.
36+
- Custom interceptors must be reachable from the EventListener sink via the address
37+
specified in the `ClusterInterceptor` resource.
38+
- TLS is used by default for core interceptors (port 8443); recommended for custom
39+
interceptors in production.
40+
41+
## Consequences
42+
43+
- Custom interceptors can be implemented in any language with an HTTP server
44+
- Core interceptors incur an in-cluster network hop from the sink (not in-process)
45+
- Adding a new core interceptor requires a change to the interceptors binary
46+
- Custom interceptor failures surface as EventListener processing errors

docs/adr/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Architecture Decision Records
2+
3+
Architectural decisions for Tekton Triggers are tracked as **Tekton Enhancement Proposals (TEPs)**
4+
in the [tektoncd/community](https://github.com/tektoncd/community/tree/main/teps) repository.
5+
6+
TEPs follow a lightweight RFC process and cover cross-cutting concerns across all Tekton projects.
7+
Triggers-specific TEPs are tagged accordingly in the community repo.
8+
9+
## Core Design Decisions
10+
11+
Key architectural decisions captured locally:
12+
13+
- [ADR-0001: Event-Driven Architecture and Component Responsibilities](./0001-event-driven-architecture.md)
14+
- [ADR-0002: Interceptor Communication via HTTP(S) Webhook](./0002-interceptor-communication.md)
15+
16+
## How to Propose Changes
17+
18+
Open a TEP in [tektoncd/community](https://github.com/tektoncd/community/blob/main/process/tep-process.md)
19+
following the TEP process for any change that affects the public API, CRD schema, or cross-component behavior.

0 commit comments

Comments
 (0)