Skip to content

Commit ae76011

Browse files
committed
chore: update readme and rules for agents
1 parent 391b812 commit ae76011

10 files changed

Lines changed: 119 additions & 7 deletions

File tree

.claude/rules/testing.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docs/rules/testing.md

.claude/rules/typescript.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docs/rules/typescript.md

.cursor/rules/testing.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docs/rules/testing.md

.cursor/rules/typescript.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docs/rules/typescript.md

AGENTS.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# AGENTS.md
2+
3+
Project: Frontend for Red Hat's Patch service (React + JavaScript + TypeScript + PatternFly React)
4+
5+
Backend: https://github.com/RedHatInsights/patchman-engine
6+
7+
## Dev environment setup
8+
- Use `nvm use` to match node version in `.nvmrc`
9+
- Run [script to patch your
10+
`/etc/hosts`](https://github.com/RedHatInsights/insights-proxy/blob/master/scripts/patch-etc-hosts.sh)
11+
- Always be connected to Red Hat VPN
12+
13+
## Commit guidelines
14+
- Follow Conventional Commits format: `type(scope): description`
15+
- Common types: `feat`, `fix`, `refactor`, `test`, `docs`, `chore`
16+
- Explain the "why" in the commit message, not the "what".
17+
- Keep commit message body no longer than 72 characters and header no longer than 50 characters

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AGENTS.md

README.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Build Status](https://img.shields.io/github/actions/workflow/status/RedhatInsights/patchman-ui/test.yml?branch=master)](https://github.com/RedHatInsights/patchman-ui/actions/workflows/test.yml)
1+
[![Build Status](https://img.shields.io/github/actions/workflow/status/RedhatInsights/patchman-ui/sentry.yml?branch=master)](https://github.com/RedHatInsights/patchman-ui/actions/workflows/sentry.yml)
22
[![GitHub release](https://img.shields.io/github/v/release/RedHatInsights/patchman-ui.svg)](https://github.com/RedHatInsights/patchman-ui/releases/latest)
33
[![codecov](https://codecov.io/gh/RedHatInsights/patchman-ui/branch/master/graph/badge.svg)](https://codecov.io/gh/RedHatInsights/patchman-ui)
44
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
@@ -9,6 +9,22 @@ Patch is one of the applications for console.redhat.com. It allows users to disp
99
their registered systems. This repository contains source code for the frontend part of the application which uses the
1010
REST API available from [Patchman Engine](https://github.com/RedHatInsights/patchman-engine).
1111

12+
<!--toc:start-->
13+
14+
- [First time setup](#first-time-setup)
15+
- [Running locally](#running-locally)
16+
- [Testing](#testing)
17+
- [Unit tests: Jest](#unit-tests-jest)
18+
- [E2E (UI & Integration) tests: Playwright](#e2e-ui--integration-tests-playwright)
19+
- [First time setup](#first-time-setup-1)
20+
- [Running UI tests](#running-ui-tests)
21+
- [Running Integration tests](#running-integration-tests)
22+
- [Deploying](#deploying)
23+
- [Design System](#design-system)
24+
- [Insights Components](#insights-components)
25+
- [AI Coding Assistants](#ai-coding-assistants)
26+
<!--toc:end-->
27+
1228
## First time setup
1329

1430
1. Make sure you have [`Node.js`](https://nodejs.org/en/) version >= 18 installed.
@@ -115,3 +131,12 @@ This app imports components
115131
from [Insights Front-end Components library](https://github.com/RedHatInsights/frontend-components). ESI tags are used
116132
to import [Insights Chrome](https://github.com/RedHatInsights/insights-chrome) which takes care of the header, sidebar,
117133
and footer.
134+
135+
## AI Coding Assistants
136+
137+
This project includes guidance for AI coding assistants (Claude Code, Cursor, etc.):
138+
139+
- **`AGENTS.md`** - Main entry point with project context, setup requirements, and workflows
140+
- **`docs/rules/`** - Topic-specific detailed rules (testing, etc.)
141+
142+
**For maintainers**: See [docs/rules/README.md](docs/rules/README.md) for how to add or modify AI assistant rules.

docs/rules/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# AI Assistant Rules
2+
3+
Topic-specific rules for AI coding assistants. Files here are automatically picked up by Claude Code and Cursor via symlinks in `.claude/rules/` and `.cursor/rules/`.
4+
5+
## Current Rules
6+
7+
- **[testing.md](testing.md)**: Playwright testing conventions and best practices
8+
- **[typescript.md](typescript.md)**: JavaScript to TypeScript migration guidance
9+
10+
## Adding New Rules
11+
12+
1. Create `docs/rules/topic-name.md` with your rules
13+
2. Create symlinks:
14+
```bash
15+
ln -s ../../docs/rules/topic-name.md .claude/rules/topic-name.md
16+
ln -s ../../docs/rules/topic-name.md .cursor/rules/topic-name.md
17+
```
18+
3. Update the "Current Rules" list above
19+
20+
**Example:**
21+
22+
```bash
23+
# Create the rule file
24+
cat > docs/rules/react.md << 'EOF'
25+
# React Component Rules
26+
27+
- Use functional components with hooks
28+
- Keep components small and focused
29+
EOF
30+
31+
# Create symlinks
32+
ln -s ../../docs/rules/react.md .claude/rules/react.md
33+
ln -s ../../docs/rules/react.md .cursor/rules/react.md
34+
```

playwright/.cursor/rules/playwright-tests-ts.mdc renamed to docs/rules/testing.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
---
2-
globs: **/*.spec.ts
3-
alwaysApply: false
4-
---
5-
6-
# Playwright Test Rules
1+
# Playwright Testing Rules
72

83
Apply these rules to TypeScript test files (`**/*spec.ts`) in the `playwright` folder.
94

docs/rules/typescript.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# TypeScript Rules
2+
3+
Apply these rules when migrating files from JavaScript to TypeScript
4+
5+
## General Guidelines
6+
7+
- Do not introduce unrelated logic changes while adding types
8+
- Favor type safety over convenience (`any` is a last resort)
9+
- Use existing project patterns and types when available
10+
- Prefer inference when it is clear and sufficient
11+
12+
## Typing Strategy
13+
14+
- Use existing types/interfaces from the codebase
15+
- Define minimal types/interfaces when needed
16+
- Use `unknown` over `any` when type is unclear
17+
- Use `any` only as a temporary fallback
18+
- Organize types in dedicated files (`types.ts`) or alongside implementations
19+
- Create a central `types.ts` file or a `src/types` directory for shared types
20+
21+
## React & Redux
22+
23+
- Type props explicitly using `type` or `interface`
24+
- Use typed hooks (`useAppDispatch`, `useAppSelector`) instead of raw Redux hooks
25+
- Type event handlers (`React.ChangeEvent`, etc.)
26+
27+
## State & Data
28+
29+
- Avoid initializing empty arrays/objects without types (`useState<Type[]>([])`)
30+
- Prevent `never[]` by explicitly typing initial state
31+
- Use union types for nullable/optional values (`string | null`)
32+
33+
## API
34+
35+
- Type all API requests and responses
36+
- If API request/response types are unclear, ask for the API spec instead of guessing

0 commit comments

Comments
 (0)