|
| 1 | +--- |
| 2 | +title: Context Structure |
| 3 | +weight: 10 |
| 4 | +--- |
| 5 | + |
| 6 | +# Context Structure |
| 7 | + |
| 8 | +This page describes the `.ai/` folder structure used in the PrestaShop core repository and the simpler context approach used in smaller repositories. |
| 9 | + |
| 10 | +## Core repository: the `.ai/` folder |
| 11 | + |
| 12 | +The [PrestaShop/PrestaShop](https://github.com/PrestaShop/PrestaShop) repository uses a hierarchical `.ai/` folder as the centralized source of truth for all AI-assisted development context. |
| 13 | + |
| 14 | +### Folder layout |
| 15 | + |
| 16 | +``` |
| 17 | +.ai/ |
| 18 | +├── CONTEXT.md # Root context: project-wide architecture and rules |
| 19 | +├── STRUCTURE.md # Documents the .ai/ folder conventions |
| 20 | +├── GOTCHAS.md # Common pitfalls and tricky patterns |
| 21 | +├── MULTISTORE.md # Multistore-specific guidance |
| 22 | +├── Domain/ |
| 23 | +│ ├── Cart/ |
| 24 | +│ │ └── CONTEXT.md # Cart domain rules and patterns |
| 25 | +│ ├── Order/ |
| 26 | +│ │ └── CONTEXT.md |
| 27 | +│ ├── Product/ |
| 28 | +│ │ └── CONTEXT.md |
| 29 | +│ └── ... # 57 domain contexts total |
| 30 | +├── Component/ |
| 31 | +│ ├── CQRS/ |
| 32 | +│ │ └── CONTEXT.md # CQRS component rules |
| 33 | +│ ├── Grid/ |
| 34 | +│ │ └── CONTEXT.md |
| 35 | +│ ├── Form/ |
| 36 | +│ │ └── CONTEXT.md |
| 37 | +│ └── ... # 22 component contexts total |
| 38 | +├── skills/ # Reusable AI task templates |
| 39 | +│ └── ... |
| 40 | +└── generated/ # Pre-generated indexes |
| 41 | + ├── cqrs.md # CQRS commands and queries index |
| 42 | + ├── routes.md # Routes index |
| 43 | + ├── entities.md # Entities index |
| 44 | + └── hooks.md # Hooks index |
| 45 | +``` |
| 46 | + |
| 47 | +### Root CONTEXT.md |
| 48 | + |
| 49 | +The [root `.ai/CONTEXT.md`](https://github.com/PrestaShop/PrestaShop/blob/develop/.ai/CONTEXT.md) is the entry point. It provides: |
| 50 | + |
| 51 | +- Project-wide architecture overview (Core Domain, Adapter, PrestaShopBundle, Legacy layers) |
| 52 | +- CQRS pattern conventions |
| 53 | +- Global coding standards (strict types, `final` classes by default, no ObjectModel in new code) |
| 54 | +- An index of all domain and component contexts |
| 55 | +- References to generated index files |
| 56 | + |
| 57 | +### Domain contexts |
| 58 | + |
| 59 | +Each domain context (e.g., [`.ai/Domain/Cart/CONTEXT.md`](https://github.com/PrestaShop/PrestaShop/blob/develop/.ai/Domain/Cart/CONTEXT.md)) provides rules specific to that business domain. They follow a standard template defined in [`.ai/STRUCTURE.md`](https://github.com/PrestaShop/PrestaShop/blob/develop/.ai/STRUCTURE.md): |
| 60 | + |
| 61 | +- **Purpose** -- what this domain covers |
| 62 | +- **Architecture overview** -- key classes, services, and their relationships |
| 63 | +- **Coding standards** -- domain-specific conventions |
| 64 | +- **Do / Don't** -- explicit rules for this domain |
| 65 | +- **Testing expectations** -- what tests are required |
| 66 | +- **Canonical examples** -- reference files to follow |
| 67 | +- **Related skills** -- links to reusable task templates |
| 68 | + |
| 69 | +### Component contexts |
| 70 | + |
| 71 | +Component contexts (e.g., `.ai/Component/CQRS/CONTEXT.md`) follow the same template but describe cross-cutting shared infrastructure like Grid, Forms, Hooks, or CQRS. These are especially important because mistakes in shared components propagate across the entire codebase. |
| 72 | + |
| 73 | +### How pointer files work |
| 74 | + |
| 75 | +Pointer files at the repository root contain no context themselves. They simply redirect the AI tool to the `.ai/` folder. For example, `CLAUDE.md` points to `.ai/CONTEXT.md`, which then references the relevant domain and component contexts. |
| 76 | + |
| 77 | +The navigation flow: |
| 78 | + |
| 79 | +``` |
| 80 | +AI tool reads pointer file (e.g., CLAUDE.md) |
| 81 | + → Follows reference to .ai/CONTEXT.md |
| 82 | + → Discovers domain context (e.g., .ai/Domain/Cart/CONTEXT.md) |
| 83 | + → Discovers component context (e.g., .ai/Component/CQRS/CONTEXT.md) |
| 84 | +``` |
| 85 | + |
| 86 | +This means that when a developer works on cart-related code with an AI assistant, the assistant can follow this chain to load the Cart domain rules, CQRS component rules, and any cross-cutting guidance it needs. |
| 87 | + |
| 88 | +## Smaller repositories |
| 89 | + |
| 90 | +The [ps_apiresources](https://github.com/PrestaShop/ps_apiresources) and [hummingbird](https://github.com/PrestaShop/hummingbird) repositories use a simpler flat structure with a single `CONTEXT.md` at the root. |
| 91 | + |
| 92 | +### ps_apiresources |
| 93 | + |
| 94 | +The [`CONTEXT.md`](https://github.com/PrestaShop/ps_apiresources/blob/develop/CONTEXT.md) covers: |
| 95 | + |
| 96 | +- Module purpose (declarative API endpoints using CQRS) |
| 97 | +- The 8 operation attributes (CQRSGet, CQRSCreate, CQRSPartialUpdate, CQRSDelete, etc.) |
| 98 | +- URI and OAuth2 scope naming conventions |
| 99 | +- Property naming rules and field mapping strategies |
| 100 | +- Testing expectations with `ApiTestCase` |
| 101 | + |
| 102 | +### hummingbird |
| 103 | + |
| 104 | +The [`CONTEXT.md`](https://github.com/PrestaShop/hummingbird/blob/develop/CONTEXT.md) covers: |
| 105 | + |
| 106 | +- Theme architecture (Smarty, SCSS with BEM, vanilla JS/TypeScript, Vite) |
| 107 | +- Strict boundaries (no business logic in themes) |
| 108 | +- `data-ps-*` attribute system for DOM bindings |
| 109 | +- SCSS layer architecture |
| 110 | +- Accessibility baseline |
| 111 | +- "Vibe coding rules" (no jQuery, strict TypeScript, TDD, Storybook, BEM) |
| 112 | + |
| 113 | +These repositories also include pointer files (`CLAUDE.md`, `.github/copilot-instructions.md`) that reference the root `CONTEXT.md`. |
| 114 | + |
| 115 | +## Canonical template reference |
| 116 | + |
| 117 | +The canonical template for writing `CONTEXT.md` files is documented in [`.ai/STRUCTURE.md`](https://github.com/PrestaShop/PrestaShop/blob/develop/.ai/STRUCTURE.md) in the core repository. Refer to it when creating new context files for domains, components, or external modules. |
0 commit comments