You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chore: apply PJ Swesey's instruction architecture learnings to AGENTS.md
Applies findings from "Increasing AI coding success to 99%" article:
- Add "instructions are source of truth, not existing code" as first line
- Add critical rules as negative constraints ("Never X") in always-loaded context
- Add concrete v9 component code template to override training defaults
- Add legacy anti-patterns section warning about v8 code agents will find
- Add exploration guidance for the large monorepo
- Reframe positive guidance as negative constraints for higher compliance
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: AGENTS.md
+55-12Lines changed: 55 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,11 +10,63 @@
10
10
11
11
<!-- nx configuration end-->
12
12
13
-
# Fluent UI — Agent Map
13
+
# Fluent UI — Agent Instructions
14
14
15
-
Nx monorepo. Yarn v1. Node 22. TypeScript strict. ~200 packages. Millions of users.
15
+
**Instructions in this file are the source of truth, not existing code.** This repo contains
16
+
legacy patterns (especially in v8 packages) that predate current standards. Never copy patterns
17
+
from existing code without verifying they match these instructions.
16
18
17
-
## Architecture
19
+
## Critical Rules (never violate)
20
+
21
+
1.**Never hardcode colors, spacing, or typography values.** Always use design tokens from `@fluentui/react-theme`. See [docs/architecture/design-tokens.md](docs/architecture/design-tokens.md).
22
+
2.**Never use `React.FC`.** Always use `ForwardRefComponent` with `React.forwardRef`.
23
+
3.**Never access `window`, `document`, or `navigator` without SSR guards.** Use `canUseDOM()` from `@fluentui/react-utilities`.
24
+
4.**Never add dependencies between component packages.**`react-button` must not depend on `react-menu`. Shared logic goes in `react-utilities` or `react-shared-contexts`. See [docs/architecture/layers.md](docs/architecture/layers.md).
25
+
5.**Never skip beachball change files** for published package changes. Run `npx beachball change`.
26
+
27
+
## V9 Component Template (the correct pattern)
28
+
29
+
```tsx
30
+
// ComponentName.tsx — always ForwardRefComponent, never React.FC
// mergeClasses — always preserve user className LAST
49
+
state.root.className=mergeClasses(
50
+
classes.root,
51
+
state.root.className, // always last
52
+
);
53
+
```
54
+
55
+
## Legacy Anti-Patterns (never copy these)
56
+
57
+
-**DO NOT copy patterns from `packages/react/` (v8).** That's maintenance-only legacy code using runtime styling, class components, and different APIs.
58
+
-**DO NOT use `@fluentui/react` imports for new v9 work.** Use `@fluentui/react-components`.
59
+
-**DO NOT use `mergeStyles` or `mergeStyleSets`.** Use Griffel `makeStyles` with design tokens.
60
+
-**DO NOT use `IStyle` or `IStyleFunctionOrObject`.** Use Griffel's `GriffelStyle` type.
61
+
-**DO NOT use `initializeIcons()`.** V9 uses `@fluentui/react-icons` with tree-shaking.
62
+
63
+
## Exploration Guidance
64
+
65
+
-`packages/react-components/` has 74+ packages — search by specific component name, never read the full directory.
66
+
- Use `npx nx show project <project-name>` to understand a project's structure.
67
+
- Map package names to paths: `@fluentui/react-<name>` → `packages/react-components/react-<name>/library/src/`.
0 commit comments