Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 48 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -424,14 +424,52 @@ backend/migrations/ database migrations (node-pg-migrate)

## Use of AI

We use AI tools as a sparring partner and as a code assistant. AI-generated code goes through the same review as other code, and we run and test it before it is merged.
Claude and ChatGPT are the main models used. The usecases for the AI tools are as follows:
- Help with planning and structuring
- Generate specified code for specified functionality
- Help with testing and fail searching
- Help with reviewing
- Help with proper documentation
- Help with keeping us in line with project guidelines
We use AI tools to plan, to write and change code and tests, to find the cause of errors, to review and to write documentation. A group member answers for every change an AI tool makes, and the change goes through the same checks and the same review as code we write ourselves.

### Tools and tasks

| Tool | Where it runs | What we use it for |
|---|---|---|
| Claude Code | In the terminal or the Claude desktop app, with access to the repository | Code and tests for one issue at a time, running `npm run check` and the tests, finding the cause of errors, a first review of pull requests, documentation, and reading other groups' repositories in the peer review |
| Cline with models from gpt.ntnu.no | In VS Code, with language models that NTNU runs on its HPC cluster | The same kind of tasks as Claude Code, from the editor |
| ChatGPT | In the browser, without access to the repository | Questions, planning, and explaining error messages and library documentation |

<!-- Each group member: check that the tools you used, and what you used them for, are in the table. -->

### Setup and shared context

- There is no shared AI configuration in the repository. Each of us runs the tools on our own machine, and local settings (`.claude/`) are kept out of git.
- The tools get the same context as a new group member would: the issue with its goal, tasks and «done when», this README, [workflow](docs/workflow.md) with the rules for language, commits and checks, and the code.
- We give a tool one issue at a time, on the issue's own branch, so that each change is small enough to read in a review. A group member commits, opens the pull request and has to be able to explain the change.

### How we check what the AI makes

- `npm run check` must pass: Prettier, ESLint, TypeScript, the tests with coverage limits, and the build.
- New behaviour gets a test, and we make sure that the test can fail: we undo the fix or break the code on purpose and check that the test goes red.
- For changes in the interface, we look at the page at desktop and phone width, and try it with the keyboard.
- Another group member reviews every pull request before it is merged (`.github/CODEOWNERS`). AI-written code is often right these days, but can be needlessly verbose and/or solve for the wrong things.
- Sometimes we ask Claude Code to review a pull request first. In the review of the VoiceOver test ([PR #144](https://git.ntnu.no/IT2810-H26/T18-Project-2/pull/144)) it ran the tests and found, among other things, a broken table row in the report and an `aria-invalid` on the stars that the `radio` role does not support. The human reviewer checked the findings and chose what to send to the author.

### Example: click targets ([#117](https://git.ntnu.no/IT2810-H26/T18-Project-2/issues/117))

**What the AI did.** The README said that every click target was at least 44 × 44 px, but nobody had measured it. We asked Claude Code to check. It wrote a script that opened 36 page states on desktop and mobile, measured every link and button, and tabbed through each page. It found about 15 kinds of standalone links and buttons that were 18 to 41 px tall, for example «Utforsk alle viner» and «Logg inn for å gi din dom». Its fix gave them a minimum height of 44 px.

**What we changed.** On a phone, the taller wine link under «Nylig dømt» pushed «· Rødvin» onto a line of its own. We made the whole card the link instead, as on the wine cards. The login box on the wine page had also grown by about 25 px, so we reduced its padding. In the README, we replaced the old claim with the real exceptions.

**How we checked it.** The script became an end-to-end test (`frontend/e2e/targets.spec.ts`). It fails if a target is too small, or if Tab reaches an element without a visible focus mark. We ran it without the CSS fix, and again with the focus outline removed, and it failed both times. Then `npm run check -- --e2e` passed, and the pull request went to review like any other.

### What we learned

- AI is good at work that is wide but simple, such as measuring every button on every page. That is slow to do by hand, so we would probably not have done it.
- It is often wrong in ways that look right. The first fix in the example passed every check and looked fine on a desktop. Only the phone view showed the problem.
- Text often sounds "right" whether it is true or not, and that holds for text written with AI too. The 44 px claim in the example was not true. Where we can, a claim in the README is now backed by a test or a measurement.
- Large changes are hard to review. When a tool writes a lot at once, the reviewer has more to read and it's easier to miss things. Small issues help, but the reviewer still has to read the code and not only the description.
- We learn less from code we did not write ourselves. That is why the person who opens the pull request has to be able to explain it.
- Our marking was not consistent. Claude Code adds a «Co-Authored-By» line to the commits it writes, and 18 commits on `main` have one, but most of the AI-assisted work has none. The git history therefore does not show how much we used AI. That is why we now mark it in the pull request instead.

### How we mark AI use

Every pull request description ends with one line that says which AI tool was used and for what, for example «AI: Claude Code wrote the first fix and the test. We changed the card layout.» If no AI was used, the line says «AI: none». We do not mark single commits.

## Plan ahead

Expand All @@ -446,7 +484,8 @@ Claude and ChatGPT are the main models used. The usecases for the AI tools are a
- [ ] CI, an enforced coverage threshold, and eslint-plugin-jsx-a11y.
- [x] Measure sustainability and fill in the budget table.
- [ ] Compress API responses and set cache header in Apache.
- [ ] Screen reader test and a written reflection on the use of AI.
- [ ] Screen reader test.
- [x] A written reflection on the use of AI.
- [x] Prettier and ESLint in the backend, like in the frontend.

### Done
Expand Down
5 changes: 3 additions & 2 deletions docs/workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
3. **Commits:** small, in English, [Conventional Commits](https://www.conventionalcommits.org/) with the issue number:
`feat(search): add filter chips (#35)`.
4. **Check:** `npm run check` passes (see below).
5. **Pull request:** links the issue (`Closes #33`) and says what was tested and how.
5. **Pull request:** links the issue (`Closes #33`), says what was tested and how, and ends with one line on AI use:
`AI: Claude Code wrote the first fix and the test. We changed the card layout.` or `AI: none`.
6. **Review:** another group member reviews (`.github/CODEOWNERS`), merges and closes the issue.
Co-authorship does not stop that person from merging.

Expand All @@ -29,5 +30,5 @@ Run from the repository root:

- **Language:** English in code, commits, PRs and docs. Norwegian (bokmål) in everything users see.
- **Docs:** update README and `docs/` in the same PR as the change.
- **AI:** allowed. AI-written code goes through the same checks and review, and we record how we used it.
- **AI:** allowed. AI-written code goes through the same checks and review, and the pull request says how we used it. See [Use of AI](../README.md#use-of-ai).
- **Personal:** time logs and contribution summaries go in Canvas/Blackboard, never in git.