|
1 | 1 | # Copilot Instructions
|
2 | 2 |
|
3 |
| -This project features an **ASP.NET Core** backend (REST API) and a **Svelte 5 TypeScript** frontend (SPA). All contributions should respect existing formatting and conventions specified in the project’s `.editorconfig`. |
| 3 | +This project features an **ASP.NET Core** backend (REST API) and a **Svelte 5 TypeScript** frontend (SPA). All contributions must respect existing formatting and conventions specified in the `.editorconfig` file. |
4 | 4 |
|
5 | 5 | ---
|
6 | 6 |
|
7 | 7 | ## 1. General Coding Guidelines
|
8 | 8 |
|
9 |
| -- **Maintain File Style & Minimal Diffs:** |
10 |
| - - Match the code style of the file. When unsure, use the style defined in the `.editorconfig`. |
11 |
| - - Keep diffs as small as possible. Preserve existing formatting, including extra spaces and comments. |
| 9 | +- **Code Style & Minimal Diffs:** |
| 10 | + - Match the file's existing style; use `.editorconfig` when unsure. |
| 11 | + - Preserve extra spaces, comments, and minimize diffs. |
12 | 12 |
|
13 |
| -- **Complete, Clear, and Modern Code:** |
14 |
| - - Write complete code for every step—no placeholders or TODOs. |
15 |
| - - Prioritize readability by using modern language features, clear naming, and clean code practices. |
16 |
| - - It's acceptable to employ defensive coding practices when needed to handle unexpected scenarios gracefully. |
| 13 | +- **Modern Code Practices:** |
| 14 | + - Write complete, runnable code—no placeholders or TODOs. |
| 15 | + - Use modern language features, clear naming conventions, and defensive coding when necessary. |
| 16 | + - Follow SOLID, DRY, and clean code principles. Remove unused code. |
17 | 17 |
|
18 |
| -- **Design Principles:** |
19 |
| - - Follow SOLID, DRY, and overall clean code principles. |
20 |
| - - Remove unused code; simplicity equals maintainability. |
21 |
| - |
22 |
| -- **Behavioral Changes:** |
23 |
| - - Flag any user-visible changes and review them carefully. |
| 18 | +- **Behavior Management:** |
| 19 | + - Flag any user-visible changes for review. |
| 20 | + - Deliver exactly what’s requested—avoid adding unnecessary features unless explicitly instructed. |
24 | 21 |
|
25 | 22 | ---
|
26 | 23 |
|
27 | 24 | ## 2. Frontend Guidelines (Svelte 5 / TypeScript SPA)
|
28 | 25 |
|
29 | 26 | - **Framework & Best Practices:**
|
30 |
| - - Built with Svelte 5 in SPA mode using TypeScript and Tailwind CSS. |
31 |
| - - Adhere to modern ES6 best practices and the ESLint recommended configuration ([standardjs](https://standardjs.com)). |
| 27 | + - Use Svelte 5 in SPA mode with TypeScript and Tailwind CSS. |
| 28 | + - Follow modern ES6 best practices and the ESLint recommended configuration ([standardjs](https://standardjs.com)). |
32 | 29 |
|
33 | 30 | - **Architecture & Components:**
|
34 |
| - - Utilize the Composite Component Pattern (similar to shadcn-svelte). |
35 |
| - - Organize code using vertical slices for features with a shared folder for common components. |
36 |
| - - **Avoid** using any server-side Svelte features. |
37 |
| - |
38 |
| -- **UI, Accessibility, and Navigation:** |
39 |
| - - Ensure excellent keyboard navigation for all front-end interactions. |
40 |
| - - Leverage shadcn-svelte components, which are built on [bits-ui](https://bits-ui.com/docs/llms.txt). |
41 |
| - - Build forms using shadcn-svelte forms & superforms, and validate with class-validator. |
42 |
| - - For icons use lucide-svelte. |
43 |
| - - Follow mobile-first responsive design, semantic HTML, and secure WCAG 2.2 Level AA compliance. |
44 |
| - |
45 |
| -- **Testing:** |
| 31 | + - Follow the Composite Component Pattern. |
| 32 | + - Organize code into vertical slices (e.g., features aligned with API controllers) and maintain shared components in a central folder. |
| 33 | + - Use **kebab-case** for filenames and directories (e.g., `components/event-overview.svelte`). |
| 34 | + - **Do NOT** use any server-side Svelte features. |
| 35 | + |
| 36 | +- **UI, Accessibility & Testing:** |
| 37 | + - Ensure excellent keyboard navigation for all interactions. |
| 38 | + - Build forms with shadcn-svelte forms & superforms, and validate with class-validator. |
| 39 | + - Ensure semantic HTML, mobile-first design, and WCAG 2.2 Level AA compliance. |
| 40 | + - Use shadcn-svelte components (based on [bits-ui](https://bits-ui.com/docs/llms.txt)). |
| 41 | + |
| 42 | +- **API Calls:** |
| 43 | + - Use TanStack Query for all API calls centralized in an `api.svelte.ts` file. |
| 44 | + - Leverage `@exceptionless/fetchclient` for network operations. |
| 45 | + |
| 46 | +- **Testing Tools:** |
46 | 47 | - Unit Testing: Vitest
|
47 | 48 | - Component Testing: Testing Library
|
48 | 49 | - E2E Testing: Playwright
|
49 | 50 |
|
50 | 51 | - **Reference:**
|
51 |
| - - Svelte 5 SPA guidelines: [https://svelte.dev/llms-full.txt](https://svelte.dev/llms-full.txt) |
| 52 | + - Svelte 5: [https://svelte.dev/llms-full.txt](https://svelte.dev/llms-full.txt) |
52 | 53 |
|
53 | 54 | ---
|
54 | 55 |
|
55 | 56 | ## 3. Backend Guidelines (ASP.NET Core / C#)
|
56 | 57 |
|
57 |
| -- **Framework & Language Features:** |
58 |
| - - Developed with the latest ASP.NET Core and C#. |
59 |
| - - Enable Nullable Reference Types. |
| 58 | +- **Framework & Features:** |
| 59 | + - Use the latest ASP.NET Core with C# and enable Nullable Reference Types. |
60 | 60 |
|
61 |
| -- **Coding Conventions & Best Practices:** |
62 |
| - - Follow guidelines from the `.editorconfig` and Microsoft's [coding conventions](https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/coding-conventions). |
63 |
| - - Adhere to Microsoft's best practices for ASP.NET Core development and [unit testing with xUnit](https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-best-practices). |
| 61 | +- **Conventions & Best Practices:** |
| 62 | + - Adhere to the `.editorconfig` file and Microsoft's [coding conventions](https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/coding-conventions). |
| 63 | + - Follow Microsoft's [unit testing best practices](https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-best-practices). |
64 | 64 |
|
65 |
| -- **Architecture Considerations:** |
66 |
| - - Factor in the inherent challenges of distributed computing when designing features. |
| 65 | +- **Architectural Considerations:** |
| 66 | + - Design services with awareness of distributed computing challenges. |
67 | 67 |
|
68 | 68 | ---
|
69 | 69 |
|
70 |
| -## 4. Performance |
| 70 | +## 4. Security Guidelines |
71 | 71 |
|
72 |
| -- **Optimizations:** |
73 |
| - - Lazy load components when possible. |
74 |
| - - Optimize images and assets. |
75 |
| - - Employ effective caching strategies. |
| 72 | +- **Best Practices:** |
| 73 | + - Sanitize all user inputs and rigorously validate data. |
| 74 | + - Follow OWASP guidelines and implement a robust Content Security Policy. |
| 75 | + - Adopt Shift-Left security practices to identify vulnerabilities early. |
76 | 76 |
|
77 | 77 | ---
|
78 | 78 |
|
79 |
| -## 5. Security |
| 79 | +## 5. Developer Planning & Reflection |
80 | 80 |
|
81 |
| -- **Data Protection & Validation:** |
82 |
| - - Sanitize all user inputs and validate data rigorously. |
83 |
| - - Follow OWASP guidelines and implement a robust Content Security Policy. |
84 |
| - - Embrace Shift-Left security practices. |
| 81 | +- **Pre-Coding Reflection:** |
| 82 | + 1. Identify the problem or feature you’re solving. |
| 83 | + 2. Consider three possible approaches. |
| 84 | + 3. Choose the simplest approach that satisfies all requirements. |
| 85 | + 4. Clarify: |
| 86 | + - Can the solution be modularized into smaller functions? |
| 87 | + - Are there unnecessary abstractions? |
| 88 | + - Will the implementation be clear to a junior developer? |
| 89 | + |
| 90 | +- **Post-Coding Reflection:** |
| 91 | + 1. Review for refactor opportunities—can clarity or maintainability be improved? |
| 92 | + 2. Identify potential edge cases or areas prone to bugs. |
| 93 | + 3. Verify robust error handling and validation mechanisms. |
85 | 94 |
|
86 | 95 | ---
|
87 | 96 |
|
88 | 97 | ## 6. Code Reviews
|
89 | 98 |
|
90 | 99 | - **Focus Areas:**
|
91 |
| - - Review for complexity, consistency, duplication, and adherence to best practices. |
92 |
| - - Verify robust error handling and the effectiveness of defensive coding when applied. |
| 100 | + - Ensure adherence to complexity, consistency, and clean code standards. |
| 101 | + - Validate robust error handling and defensive coding practices. |
| 102 | + - Check for duplication and maintainable solutions. |
93 | 103 |
|
94 | 104 | ---
|
95 | 105 |
|
96 | 106 | ## 7. Debugging Guidelines
|
97 | 107 |
|
98 |
| -1. **Reproduce** the issue using minimal steps and code. |
99 |
| -2. **Understand** the core problem. |
100 |
| -3. **Hypothesize** the root cause. |
101 |
| -4. **Test & Verify** the solution. |
102 |
| -5. **Document** the fix and any adjustments made. |
| 108 | +1. **Reproduce** the issue with minimal steps and code. |
| 109 | +2. **Understand** the underlying problem thoroughly. |
| 110 | +3. **Form Hypotheses** about the cause. |
| 111 | +4. **Test & Verify** potential solutions. |
| 112 | +5. **Document** fixes and adjustments clearly for future reference. |
103 | 113 |
|
104 | 114 | ---
|
105 | 115 |
|
106 |
| -## 8. Project Structure |
| 116 | +## 8. Developer Planning & Reflection |
| 117 | + |
| 118 | +### Pre-Coding Reflection |
| 119 | + |
| 120 | +Before implementing your solution, reflect on the following steps: |
| 121 | + |
| 122 | +1. **Core Requirement:** Identify the problem or feature you need to implement. |
| 123 | +2. **Approach Comparison:** Consider three possible approaches to the implementation. |
| 124 | +3. **Simplicity First:** Choose the simplest approach that meets all requirements. |
| 125 | +4. **Clarifying Questions:** Ask: |
| 126 | + - Can this be split into smaller functions? |
| 127 | + - Are there unnecessary abstractions? |
| 128 | + - Will this be clear to a junior |
| 129 | + |
| 130 | +## 9. Project Structure |
107 | 131 |
|
108 | 132 | ```plaintext
|
109 | 133 | project-root/
|
|
0 commit comments