|
1 | | -# Copilot Instructions |
| 1 | +--- |
| 2 | +# Configuration for Copilot in this project |
| 3 | +applyTo: "**/*.{ts,tsx,js,jsx,md}" # apply to all code files by default |
| 4 | +--- |
2 | 5 |
|
3 | | -These instructions define how GitHub Copilot should assist in this project. |
4 | | -They are tailored to our selected IDE, framework, and coding conventions, based on real developer practices. |
| 6 | +# Project Overview |
| 7 | +These are the conventions and guardrails Copilot should follow when generating code, tests, commits, and PRs in our project. |
| 8 | +They reflect the decisions we made (IDE, framework, language) and real-world best practices. |
5 | 9 |
|
6 | 10 | --- |
7 | 11 |
|
8 | | -## Environment |
| 12 | +## 1. Project Context & Priorities |
| 13 | + |
| 14 | +- IDE: **{{preferredIde}}** |
| 15 | +- Framework: **{{frameworkSelection}}** |
| 16 | +- Build tooling: **{{tooling}}** |
| 17 | +- Language: **{{language}}** |
9 | 18 |
|
10 | | -- **IDE**: {{preferredIde}} |
11 | | -- **Framework**: {{frameworkSelection}} |
12 | | -- **Build Tooling**: {{tooling}} |
13 | | -- **Language**: {{language}} |
| 19 | +- Primary focus: **{{projectPriority}}** |
| 20 | + |
| 21 | +> Use this context — when Copilot needs to choose between simpler vs. more optimized code, prefer what aligns with **{{projectPriority}}**. |
14 | 22 |
|
15 | 23 | --- |
16 | 24 |
|
17 | | -## Project Priorities |
| 25 | +## 2. Naming, Style & Structure Rules |
| 26 | + |
| 27 | +### Naming & Exports |
18 | 28 |
|
19 | | -- **Primary focus**: {{projectPriority}} |
20 | | -- **Code style**: {{codeStyle}} |
21 | | -- **Variable naming**: {{variableNaming}} |
22 | | -- **File naming**: {{fileNaming}} |
23 | | -- **Component naming**: {{componentNaming}} |
24 | | -- **Exports**: {{exports}} |
25 | | -- **Comments & documentation**: {{comments}} |
26 | | -- **Collaboration rules**: {{collaboration}} |
| 29 | +- Variables, functions, object keys: **{{variableNaming}}** |
| 30 | +- Files & modules: **{{fileNaming}}** |
| 31 | +- Components, types: **{{componentNaming}}** |
| 32 | +- Always use **{{exports}}** exports style |
| 33 | +- Comments & documentation style: **{{comments}}** |
| 34 | +- Code style: follow **{{codeStyle}}** |
| 35 | + |
| 36 | +### File and Folder Structure |
| 37 | + |
| 38 | +- Component / UI layout organization: **{{fileStructure}}** |
| 39 | +- Styling approach: **{{styling}}** |
| 40 | +- State management: adopt **{{stateManagement}}** |
| 41 | +- API layer organization: put remote calls in **{{apiLayer}}** |
| 42 | +- Folder strategy: **{{folders}}** |
| 43 | + |
| 44 | +> Copilot should not generate code outside these structures or naming patterns. |
27 | 45 |
|
28 | 46 | --- |
29 | 47 |
|
30 | | -## Architecture & Structure |
| 48 | +## 3. Testing & Quality Assurance |
| 49 | + |
| 50 | +- Unit tests: **{{testingUT}}** |
| 51 | +- E2E / integration: **{{testingE2E}}** |
31 | 52 |
|
32 | | -- **Component structure**: {{fileStructure}} |
33 | | -- **Styling approach**: {{styling}} |
34 | | -- **State management**: {{stateManagement}} |
35 | | -- **API layer**: {{apiLayer}} |
36 | | -- **Folder structure**: {{folders}} |
| 53 | +**Rules** |
| 54 | +- Use descriptive test names. |
| 55 | +- Always include both “happy path” and edge cases. |
| 56 | +- Avoid large tests that span too many modules. |
| 57 | +- Tests should live alongside modules (or in designated `__tests__` folder per convention). |
37 | 58 |
|
38 | 59 | --- |
39 | 60 |
|
40 | | -## Testing |
| 61 | +## 4. Performance & Data Loading |
41 | 62 |
|
42 | | -- **Unit testing**: {{testingUT}} |
43 | | -- **End-to-End (E2E) testing**: {{testingE2E}} |
| 63 | +- Data fetching approach: **{{dataFetching}}** |
| 64 | +- React performance optimizations: **{{reactPerf}}** |
| 65 | + |
| 66 | +**Do** |
| 67 | +- Use pagination or limit responses. |
| 68 | +- Memoize computations or components when data is large. |
| 69 | +- Lazy-load modules/components that aren’t critical at startup. |
| 70 | + |
| 71 | +**Don’t** |
| 72 | +- Fetch all data at once without constraints. |
| 73 | +- Place heavy logic in render without memoization. |
44 | 74 |
|
45 | 75 | --- |
46 | 76 |
|
47 | | -## Performance Guidelines |
| 77 | +## 5. Security, Validation, Logging |
48 | 78 |
|
49 | | -- **Data fetching**: {{dataFetching}} |
50 | | -- **React performance**: {{reactPerf}} |
| 79 | +- Secrets / auth handling: **{{auth}}** |
| 80 | +- Input validation: **{{validation}}** |
| 81 | +- Logging style: **{{logging}}** |
| 82 | + |
| 83 | +**Rules** |
| 84 | +- Never embed secrets in code; always use environment variables. |
| 85 | +- Validate all incoming data (API or client side) using the chosen validation library. |
| 86 | +- Logging messages should never reveal secrets or PII. |
| 87 | +- Use structured or contextual logs (vs. free-form `console.log`) especially in production. |
51 | 88 |
|
52 | 89 | --- |
53 | 90 |
|
54 | | -## Security Guidelines |
| 91 | +## 6. Commit & PR Conventions |
| 92 | + |
| 93 | +- Commit message style: **{{commitStyle}}** |
| 94 | +- PR rules: **{{prRules}}** |
55 | 95 |
|
56 | | -- **Authentication & secrets**: {{auth}} |
57 | | -- **Validation**: {{validation}} |
58 | | -- **Logging**: {{logging}} |
| 96 | +**Do** |
| 97 | +- Write commit messages that follow the agreed style (e.g. `feat: add login`) |
| 98 | +- Keep PRs small and focused |
| 99 | +- Always link the issue or ticket |
| 100 | +- If PR introduces new API or breaking change, update the documentation |
| 101 | + |
| 102 | +**Don’t** |
| 103 | +- Use vague commit messages like “fix stuff” |
| 104 | +- Combine unrelated changes in one commit or PR |
59 | 105 |
|
60 | 106 | --- |
61 | 107 |
|
62 | | -## Commits & Pull Requests |
| 108 | +## 7. Copilot Usage Guidance |
63 | 109 |
|
64 | | -- **Commit style**: {{commitStyle}} |
65 | | -- **Pull request rules**: {{prRules}} |
| 110 | +- Use Copilot to scaffold boilerplate (e.g. `useQuery`, component boilerplate), not to bypass core logic. |
| 111 | +- When writing prompts/comments for Copilot, embed **context** (e.g. expected return shape, types). |
| 112 | +- When Copilot suggests code that violates naming, structure, or validation rules – override or reject it. |
| 113 | +- For ambiguous design choices, ask for clarification in comments (e.g. “// Should this go in services or hooks?”). |
| 114 | +- Prefer completions that respect folder boundaries and import paths (don’t let Copilot propose imports from “wrong” layers). |
66 | 115 |
|
67 | 116 | --- |
68 | 117 |
|
69 | | -## IDE-Specific Guidance |
| 118 | +## 8. IDE-Specific Rules & Settings |
| 119 | + |
| 120 | +For **VS Code**: |
70 | 121 |
|
71 | | -For **VS Code**: |
72 | | -- Always include a `.editorconfig`. |
73 | | -- Enable **Prettier** and **ESLint** extensions. |
74 | | -- Turn on `editor.formatOnSave: true`. |
75 | | -- Suggested extensions: |
76 | | - - `dbaeumer.vscode-eslint` |
77 | | - - `esbenp.prettier-vscode` |
78 | | - - `formulahendry.auto-rename-tag` |
| 122 | +- Use `.editorconfig` for consistent indent / line endings |
| 123 | +- Enable **Prettier** and **ESLint**, synced to our style rules |
| 124 | +- Set `editor.formatOnSave = true` |
| 125 | +- Suggested extensions: `dbaeumer.vscode-eslint`, `esbenp.prettier-vscode`, `formulahendry.auto-rename-tag` |
| 126 | +- Avoid conflicting formatters or duplicated rules |
| 127 | + |
| 128 | +> These help Copilot suggestions align more closely with how your code will be formatted and linted. |
79 | 129 |
|
80 | 130 | --- |
81 | 131 |
|
82 | | -## Copilot Usage Guidelines |
| 132 | +## 9. Caveats & Overrides |
83 | 133 |
|
84 | | -- Use Copilot to generate **boilerplate**, but always review before committing. |
85 | | -- When writing tests, describe expected behavior clearly so Copilot can produce meaningful cases. |
86 | | -- Prefer completions aligned with **our conventions** (naming, structure, testing). |
87 | | -- Reject or edit Copilot suggestions that break the rules above. |
| 134 | +- If a feature is experimental or out-of-scope, document it in comments. |
| 135 | +- In rare cases, exceptions may be allowed — but always document why. |
| 136 | +- Always run linters and tests on generated code before merging. |
88 | 137 |
|
89 | 138 | --- |
90 | 139 |
|
91 | 140 | ## Notes |
92 | 141 |
|
93 | | -- This file is auto-generated by **DevContext**. |
94 | | -- Regenerate this file whenever project priorities, frameworks, or rules change. |
| 142 | +- This instructions file was **auto-generated** based on your chosen configuration. |
| 143 | +- Regenerate it whenever your JSON configuration changes (framework, naming, testing, etc.). |
| 144 | +- You may also split this file into domain-specific `.instructions.md` files using `applyTo` frontmatter if your project grows. |
| 145 | + |
0 commit comments