Skip to content

Commit 1606b83

Browse files
committed
docs: add AGENTS.md and modular documentation structure
Add AGENTS.md as a project guide with links to focused docs/ files: build.md, release.md, testing.md, code-conventions.md, ci.md, yaml-generation.md, and contributing.md. Merged getting-started.md and onboarding-new-task.md into the new files to eliminate duplication. Code was assisted by Cursor AI. Signed-off-by: Karel Simon <ksimon@redhat.com>
1 parent d59a65d commit 1606b83

18 files changed

+616
-88
lines changed

.claude/CLAUDE.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Claude Code Instructions
2+
3+
**CRITICAL**: This project uses a structured documentation system. Before any work:
4+
5+
1. **Read [AGENTS.md](../AGENTS.md)** - Complete project guide with structure, commands, and common mistakes
6+
2. **Read [AI Workflow Rules](docs/ai-workflow.md)** - **MANDATORY** 2-step process: planning → approval → implementation
7+
8+
## Do not proceed without reading these files first!
9+
10+
## Key Rules
11+
12+
- **NEVER hand-edit `release/` files** - Always edit templates, then run `make generate-yaml-tasks` (see [YAML Generation](docs/yaml-generation.md))
13+
- **Always vendor after dependency changes** - Run `make vendor` after any `go.mod` changes
14+
- **Use the 2-step workflow** - Create `change.md` plan first, wait for approval, then implement
15+
- **Sign all commits** - Use `git commit --signoff` (DCO requirement)
16+
17+
## Quick Reference
18+
19+
All documentation is in `docs/`:
20+
- [AI Workflow](docs/ai-workflow.md) - 2-step planning process
21+
- [Build & Dependencies](docs/build.md)
22+
- [YAML Generation](docs/yaml-generation.md)
23+
- [Code Conventions](docs/code-conventions.md)
24+
- [Testing](docs/testing.md)
25+
- [CI / GitHub Actions](docs/ci.md)
26+
- [Release](docs/release.md)
27+
- [Contributing](docs/contributing.md)
28+
29+
See [AGENTS.md](../AGENTS.md) for the complete project guide including common commands and troubleshooting.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
description: Always read the AGENTS.md project guide before starting any task
3+
alwaysApply: true
4+
---
5+
6+
# Read AGENTS.md First
7+
8+
Before doing any work in this repository, **always** read the file `AGENTS.md` at the project root first. It contains the project guide, required AI workflow rules, documentation index, project structure, and common commands.
9+
10+
This is mandatory for every conversation — do not skip it, even if you think you already know the project layout.

.cursorrules

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Cursor AI Instructions
2+
3+
**CRITICAL**: This project uses a structured documentation system. Before any work:
4+
5+
1. **Read AGENTS.md** - Complete project guide with structure, commands, and common mistakes
6+
2. **Read docs/ai-workflow.md** - **MANDATORY** 2-step process: planning → approval → implementation
7+
8+
## Key Rules
9+
10+
- **NEVER hand-edit `release/` files** - Always edit templates, then run `make generate-yaml-tasks`
11+
- **Always vendor after dependency changes** - Run `make vendor` after any `go.mod` changes
12+
- **Use the 2-step workflow** - Create `change.md` plan first, wait for approval, then implement
13+
- **Sign all commits** - Use `git commit --signoff` (DCO requirement)
14+
15+
## Quick Reference
16+
17+
All documentation is in `docs/`:
18+
- AI Workflow: docs/ai-workflow.md - 2-step planning process
19+
- Build & Dependencies: docs/build.md
20+
- YAML Generation: docs/yaml-generation.md - **NEVER hand-edit `release/` files**
21+
- Code Conventions: docs/code-conventions.md
22+
- Testing: docs/testing.md
23+
- CI / GitHub Actions: docs/ci.md
24+
- Release: docs/release.md
25+
- Contributing: docs/contributing.md
26+
27+
See AGENTS.md for the complete project guide including common commands and troubleshooting.

.env.example

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Jira MCP Server Credentials
2+
# Copy this file to .env.jira and fill in your credentials
3+
4+
# Your Atlassian site name (e.g., "redhat" for redhat.atlassian.net)
5+
ATLASSIAN_SITE_NAME="redhat"
6+
7+
# Your Atlassian account email
8+
ATLASSIAN_USER_EMAIL="your.email@redhat.com"
9+
10+
# API token from https://id.atlassian.com/manage-profile/security/api-tokens
11+
ATLASSIAN_API_TOKEN="your-api-token-here"

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33
ah
44
/manifests/
55
/test/test.test
6+
.env*
7+
!.env.example
8+
change.md

AGENTS.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# KubeVirt Tekton Tasks - Project Guide
2+
3+
> **Last Updated:** 2026-03-26 | **For:** All AI Agents
4+
5+
KubeVirt-specific Tekton tasks for CI/CD pipelines on Kubernetes. Provides tasks for creating/managing VMs, executing commands over SSH, manipulating disk images with libguestfs, and uploading disk images to container registries.
6+
7+
**IMPORTANT for AI Agents**: See [AI Workflow Rules](docs/ai-workflow.md) for the required 2-step planning and approval process before modifying any code.
8+
9+
## Jira Task Management
10+
11+
When the user references a Jira task (e.g., "read CNV-82681" or "check issue CNV-12345"):
12+
13+
1. **Use acli to fetch task information**:
14+
```bash
15+
acli jira workitem view <TASK-ID> --fields '*all'
16+
```
17+
18+
2. **Examples**:
19+
```bash
20+
# View complete task information
21+
acli jira workitem view CNV-82681 --fields '*all'
22+
23+
# View specific fields only
24+
acli jira workitem view CNV-82681 --fields summary,description,status,assignee
25+
```
26+
27+
## Documentation
28+
29+
| Document | Description |
30+
|----------|-------------|
31+
| [AI Workflow Rules](docs/ai-workflow.md) | **Required 2-step process for AI agents** (planning → approval → implementation) |
32+
| [Build & Dependencies](docs/build.md) | Build system, Go/container toolchain, supported environments |
33+
| [YAML Generation](docs/yaml-generation.md) | Ansible-driven task YAML generation pipeline (**never hand-edit `release/`**) |
34+
| [Code Conventions](docs/code-conventions.md) | Go module structure, testing patterns, error handling, formatting |
35+
| [Testing](docs/testing.md) | Unit tests, E2E tests, `DEV_MODE` for local images |
36+
| [CI / GitHub Actions](docs/ci.md) | Workflow descriptions, Dependabot, Renovate |
37+
| [Release](docs/release.md) | Release process, version bumping, artifacts |
38+
| [Contributing](docs/contributing.md) | PR requirements, code quality workflow, adding new tasks |
39+
| [Tasks RBAC Permissions](docs/tasks-rbac-permissions.md) | ServiceAccount, ClusterRole, RoleBinding setup |
40+
41+
## Project Structure
42+
43+
```
44+
cmd/ # One main.go per compiled task binary
45+
create-vm/
46+
execute-in-vm/
47+
generate-ssh-keys/
48+
modify-data-object/
49+
wait-for-vmi-status/
50+
disk-uploader/
51+
disk-virt-customize/
52+
disk-virt-sysprep/
53+
modules/ # Go libraries and per-task packages + tests
54+
shared/pkg/... # Shared utilities (env, log, output, zconstants, zerrors, zutils)
55+
sharedtest/... # Shared test helpers
56+
<task>/pkg/... # Per-task logic
57+
disk-virt/ # Shared by disk-virt-customize and disk-virt-sysprep
58+
build/ # Containerfiles and entrypoint scripts
59+
Containerfile # Multi-stage: CentOS Stream 10 builder + runtime
60+
Containerfile.DiskVirt # Builds disk-virt tasks on libguestfs-tools base
61+
configs/ # Per-task Ansible variable files
62+
templates/ # Ansible-driven Tekton task YAML generation
63+
<task>/manifests/ # Generated task manifests
64+
<task>/generate-task.yaml # Ansible playbook for YAML generation
65+
templates-pipelines/ # Pipeline YAML generation (Windows pipelines)
66+
release/ # Published task and pipeline YAML artifacts
67+
tasks/<task>/
68+
pipelines/<pipeline>/
69+
scripts/ # Shell automation for build, test, lint, deploy
70+
makefile-snippets/ # Included makefile fragments
71+
test/ # Ginkgo E2E integration tests and framework
72+
automation/ # E2E orchestration, resource deployment, CI helpers
73+
vendor/ # Vendored Go modules (GOFLAGS=-mod=vendor)
74+
docs/ # Developer and user documentation
75+
```
76+
77+
### Key relationships
78+
79+
- `cleanup-vm` is generated from `execute-in-vm` templates (with `is_cleanup: true`), not a separate binary.
80+
- `modify-windows-iso-file` exists as templates and release YAML only (no `cmd/` entry).
81+
- `disk-virt-customize` and `disk-virt-sysprep` share `modules/disk-virt/`.
82+
83+
## Common AI Agent Mistakes & Quick Fixes
84+
85+
| Mistake | Why It Happens | How to Fix |
86+
|---------|---------------|------------|
87+
| Hand-editing `release/` files | Not reading yaml-generation.md | Always edit templates, then run `make generate-yaml-tasks` |
88+
| Missing vendored dependencies | After adding/updating Go modules | Run `make vendor` after any `go.mod` change |
89+
| Skipping the 2-step workflow | Eagerness to implement | Always create `change.md` first, wait for approval |
90+
| Forgetting DCO sign-off | Not following git workflow | Use `git commit --signoff` |
91+
| Using testify instead of Ginkgo | Following common Go patterns | Check code-conventions.md - we use Ginkgo/Gomega |
92+
| Bumping Go version on release branch | Assuming newer is better | Never bump Go on release branches (breaks midstream) |
93+
94+
## Common Commands
95+
96+
| Command | Description |
97+
|---------|-------------|
98+
| `make clean` | Clean build artifacts |
99+
| `make generate-yaml-tasks` | Generate task YAML from templates |
100+
| `make generate-pipelines` | Generate pipeline YAML |
101+
| `make test` | Run unit tests |
102+
| `make lint` / `make lint-fix` | Check / fix formatting |
103+
| `make test-yaml-consistency` | Verify YAML consistency |
104+
| `make cluster-sync` | Build, push, deploy to cluster |
105+
| `make cluster-test` | Run E2E tests on cluster |
106+
| `make cluster-clean` | Clean cluster resources |
107+
| `make e2e-tests` | Full E2E: deploy + test |
108+
| `make vendor` | Vendor Go dependencies |
109+
| `make release` | Full release pipeline |
110+
| `make deploy` / `make undeploy` | Deploy/remove tasks |

CONTRIBUTING.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ Any help is highly appreciated.
3131
relevant flows should be covered via unit tests and functional tests. So when
3232
thinking about a contribution, also think about testability. All tests can be
3333
run local without the need of CI. Have a look at the
34-
[Testing](docs/getting-started.md#testing)
35-
section in the [Developer Guide](docs/getting-started.md).
34+
[Testing](docs/testing.md) documentation.
3635

3736
### Contributor compliance with Developer Certificate Of Origin (DCO)
3837
We require every contributor to certify that they are legally permitted to contribute to our project. A contributor expresses this by consciously signing their commits, and by this act expressing that they comply with the Developer Certificate Of Origin
@@ -47,5 +46,5 @@ This can be done by adding --signoff to your git command line.
4746
Before your PR can be merged it must meet the following criteria:
4847

4948
- README.md has been updated if new task is added or functionality of existing tasks is affected.
50-
- [Onboarding a New Task](docs/onboarding-new-task.md) has been taken into account when introducing a new task
49+
- [Adding a New Task](docs/contributing.md#adding-a-new-task) process has been followed when introducing a new task
5150
- Functionality must be fully tested.

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,5 @@ Then, a VM is created from such image.
100100

101101
## Development Guide
102102

103-
See [Getting Started](docs/getting-started.md) for the environment setup and development workflow.
103+
- See [AGENTS.md](AGENTS.md) for project structure, documentation index, and common commands
104+
- See [Getting Started](docs/getting-started.md) for environment setup and development workflow

docs/ai-workflow.md

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# AI Agent Workflow Rules
2+
3+
Whenever you are given a task to modify, refactor, or create ANY files in this project (code, documentation, configuration, makefiles, scripts, YAML, etc.), you MUST strictly follow this 2-step process. Do not skip steps.
4+
5+
## STEP 1: Planning and Documentation
6+
7+
1. Before writing or modifying any project code, create or update a file named `change.md` in the root directory.
8+
2. In `change.md`, clearly outline:
9+
- The goal of the task.
10+
- The files that will be modified or created.
11+
- A step-by-step technical plan of the exact changes you intend to make.
12+
- **Note:** `change.md` is gitignored and temporary - it's only used during the current task session for planning purposes.
13+
3. **CRITICAL INSTRUCTION:** Once you have saved `change.md`, you must **STOP**. Do not write any code. Ask the user: *"I have outlined the plan in change.md. Please review it. Reply with 'APPROVED' to proceed, or let me know what needs to be changed."*
14+
4. Wait for the user's explicit approval.
15+
16+
## STEP 2: Implementation
17+
18+
1. ONLY after the user explicitly types "APPROVED" (or a clear affirmative), you may begin implementing the steps exactly as outlined in `change.md`.
19+
2. Do not deviate from the approved plan without asking for permission first.
20+
3. **Before completing implementation, follow the Review Checklist below**.
21+
22+
### Review Checklist
23+
24+
**IMPORTANT**: This checklist MUST be followed:
25+
- When implementing changes (after coding, before committing)
26+
- When performing standalone code reviews (when asked to review code without implementing)
27+
28+
#### Documentation Review
29+
30+
Check if changes require updates to `docs/` files:
31+
- New features, tasks, or commands
32+
- Modified behavior or configuration
33+
- New dependencies or build requirements
34+
- Changed workflows or processes
35+
- Update relevant documentation files before proceeding
36+
- If unsure whether docs need updating, ask the user
37+
38+
#### Manifest Regeneration Review
39+
40+
Check if changes require regenerating YAML manifests:
41+
- **NEVER hand-edit files in `release/`** (see [YAML Generation](yaml-generation.md))
42+
- Run `make generate-yaml-tasks` if changes affect:
43+
- Files in `templates/` directory
44+
- Files in `configs/` (Ansible variable files)
45+
- Task parameters or behavior
46+
- RBAC requirements in task definitions
47+
- Run `make generate-pipelines` if changes affect:
48+
- Files in `templates-pipelines/` directory
49+
- Pipeline definitions or structure
50+
- Run `make test-yaml-consistency` to verify YAML is in sync
51+
- Commit any regenerated YAML files along with code changes
52+
53+
#### Code Quality Review
54+
55+
Verify code meets project standards:
56+
- Run `make lint` to check code formatting and style
57+
- Fix any linter issues with `make lint-fix`
58+
- Ensure all linter checks pass before committing
59+
- Run `make test` to verify unit tests still pass
60+
- Address any test failures before proceeding
61+
62+
### After Implementation
63+
64+
Once implementation and the review checklist are complete, **ask the user** if they would like to proceed with committing and pushing the changes to GitHub (STEP 3). Do not automatically proceed to STEP 3 without user confirmation.
65+
66+
## STEP 3: Git Workflow
67+
68+
After successfully implementing the changes:
69+
70+
1. **Create or verify your feature branch**:
71+
- If you're already on a feature branch for this work, stay on it
72+
- Otherwise, create a new branch with a descriptive name:
73+
```bash
74+
git checkout -b feature/descriptive-name
75+
# or
76+
git checkout -b fix/issue-description
77+
```
78+
79+
2. **Commit changes** following the commit message guidelines:
80+
- **Format**: `type(scope): description`
81+
- **Types**: `feat`, `fix`, `docs`, `test`, `build`, `refactor`
82+
- **Subject line**: Imperative mood, max 72 chars, capitalized, no period
83+
- **Body**: Wrap at 72 chars, explain what and why
84+
- **DCO**: Always use `--signoff`
85+
86+
Example:
87+
```bash
88+
git add <files>
89+
git commit --signoff -m "feat(execute-in-vm): Add support for custom SSH timeout
90+
91+
Implements configurable SSH timeout parameter to handle slow VM boots.
92+
Default timeout remains 5 minutes for backwards compatibility."
93+
```
94+
95+
3. **Push to origin**:
96+
```bash
97+
git push origin feature/descriptive-name
98+
```
99+
100+
4. **Inform the user** that the branch has been pushed and provide the branch name for PR creation.
101+
102+
## Jira Task Management
103+
104+
See [AGENTS.md - Jira Task Management](../AGENTS.md#jira-task-management) for instructions on fetching Jira task information.
105+
106+
When working on Jira-related changes, include the task ID and relevant information in `change.md` and commit messages.
107+
108+
## Why This Process?
109+
110+
- **Prevents mistakes**: Plan is reviewed before implementation
111+
- **Saves time**: Avoids implementing wrong solutions
112+
- **Builds trust**: User has full visibility and control
113+
- **Improves quality**: Thoughtful planning leads to better code
114+
115+
## Example Workflow
116+
117+
```
118+
User: "Add a new Tekton task for disk snapshot"
119+
120+
AI: [Creates change.md with detailed plan]
121+
AI: "I have outlined the plan in change.md. Please review it.
122+
Reply with 'APPROVED' to proceed, or let me know what needs
123+
to be changed."
124+
125+
User: [Reviews change.md, suggests modifications]
126+
127+
AI: [Updates change.md based on feedback]
128+
129+
User: "APPROVED"
130+
131+
AI: [Implements the plan step by step]
132+
AI: [Creates branch, commits with DCO sign-off, pushes to origin]
133+
AI: "Changes have been pushed to branch 'feature/disk-snapshot-task'.
134+
You can now create a PR on GitHub."
135+
```
136+
137+
---
138+
← Back to [AGENTS.md](../AGENTS.md) | [Documentation Index](../AGENTS.md#documentation)

0 commit comments

Comments
 (0)