Skip to content

Commit dad2a8e

Browse files
committed
Add comprehensive coding guidelines and project structure documentation
- Introduced CSS guidelines for maintainable and readable styles. - Added HTML coding standards focusing on accessibility and semantics. - Established JavaScript/TypeScript coding standards emphasizing simplicity and performance. - Created Markdown content rules for consistent documentation practices. - Defined project file structure for better organization. - Implemented security guidelines based on OWASP Top 10 best practices. - Outlined testing and TDD instructions for reliable code development. - Documented tooling instructions detailing libraries and frameworks used. - Established UI guidelines for accessible and maintainable user interfaces. - Added prompts for code review and custom instruction evaluation. - Introduced specification-driven workflow documentation for structured development. - Configured VSCode settings for enhanced Copilot integration. - Created a README to provide an overview of the repository and its features.
0 parents  commit dad2a8e

21 files changed

+1446
-0
lines changed

.github/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
## GitHub Copilot Custom Instructions & Prompts
2+
3+
Welcome to this project! In this repository, GitHub Copilot is configured to use custom instructions and specific prompts. This ensures Copilot generates code that better matches the requirements and guidelines of this project.
4+
5+
### What are custom instructions?
6+
Custom instructions are additional guidelines provided to Copilot. With these, Copilot can:
7+
- Follow specific code styles or conventions
8+
- Prefer certain frameworks or libraries
9+
- Generate answers and code in the desired language (for example, English)
10+
- Apply project-specific best practices
11+
12+
### How does it work?
13+
1. **Prompts**: When you give Copilot a prompt (question or task), the custom instructions are automatically included in the context.
14+
2. **Automatic application**: Copilot applies these instructions when generating code, documentation, or explanations.
15+
3. **Consistency**: This keeps the code consistent and aligned with project agreements.
16+
17+
### Examples of custom instructions
18+
- Always use semantic HTML.
19+
- Write CSS using the BEM methodology.
20+
- Provide explanations in English.
21+
- Do not use inline styles.
22+
23+
### Tips for using Copilot with custom instructions
24+
- Make your prompts clear and specific.
25+
- Indicate if you want to deviate from the standard instructions.
26+
- Always review the generated code for correctness and style.
27+
28+
29+
### Using the code review prompt in Visual Studio Code
30+
31+
In this repository, you will find a detailed system prompt for reviewing trainee code in `.github/prompts/code-review.prompt.md`. This prompt is designed to provide AI systems, such as GitHub Copilot Chat or other AI plugins in Visual Studio Code, with clear review criteria and feedback style.
32+
33+
**How to use the code review prompt:**
34+
1. Open Copilot
35+
2. Add the files/folders you want to review by clicking the 📎, or by dragging them in.
36+
3. Start by typing `/` and select `/code-review`.
37+
4. You can add extra instructions if you want, but this is optional.
38+
5. Press `enter` and the code review will be performed.
39+
40+
**Tip:** You can also customize this prompt to your own needs or expand it with project-specific points of attention.
41+
42+
### Want to know more?
43+
For more information about setting up custom instructions in Copilot, see the [official documentation](https://docs.github.com/en/copilot).

.github/copilot-instructions.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
**GitHub Copilot Instructions**
2+
3+
> A guide to help us get the best out of GitHub Copilot across our projects.
4+
5+
6+
## 🧱 Project Overview
7+
8+
This repository is a starter kit for rapid prototyping with modern web technologies. It aims to provide a maintainable, accessible, and efficient foundation for full-stack development.
9+
10+
**Tech stack:** React (frontend), Node.js (backend), Vitest (testing), CSS modules.
11+
12+
13+
14+
## 🎯 Purpose
15+
16+
This repository contains guidelines and best practices for using GitHub Copilot in our team. Reference these instruction files for:
17+
- Readable & maintainable code
18+
- Efficient performance
19+
- Consistent style across projects
20+
21+
## 🔧 General Guidelines
22+
23+
- Code language: English only
24+
- Best practices: Follow SOLID, DRY, and KISS principles throughout all code
25+
- Comments & docs: Write clear, concise JSDoc/TSDoc or XML comments where needed
26+
27+
---
28+
29+
30+
## 📚 Table of Contents
31+
32+
- **UI Guidelines**: Accessibility, design system, and styling principles for consistent, usable, and maintainable user interfaces.
33+
[Read more](./instructions/ui-guidelines.instructions.md)
34+
- **Project and Folder Structure**: Key directories and their roles in the project.
35+
[Read more](./instructions/project-file-structure.instructions.md)
36+
- **Tools, Libraries & Frameworks Instructions**: Core technologies, frameworks, and their versions used in this repository.
37+
[Read more](./instructions/tools.instructions.md)
38+
- **Coding Instructions**: Practical coding standards for JavaScript/TypeScript, CSS, and components, including semicolons, quotes, and function-based patterns.
39+
[Read more](./instructions/coding.instructions.md)
40+
- **Commit Message Instructions**: Conventional Commits format for clear, consistent commit messages.
41+
[Read more](./instructions/commit.instructions.md)
42+
- **Testing & TDD Instructions**: Test-driven development process, recommended tools, and test naming conventions.
43+
[Read more](./instructions/testing.instructions.md)
44+
- **Configuration Files Instructions**: Standards for configuration files such as .editorconfig, Prettier, and ESLint.
45+
[Read more](./instructions/config.instructions.md)
46+
- **Best Practices Instructions**: Universal coding principles (SOLID, DRY, KISS) for maintainable and efficient code.
47+
[Read more](./instructions/best-practices.instructions.md)
48+
49+
---
50+
51+
## User interactions
52+
- Ask questions if you are unsure about the implementation details, design choices, or need clarification on the requirements
53+
- Always answer in the same language as the question, but use English for the generated content like code, comments or docs
54+
- Do not adopt a specific tone or persona; focus on technical accuracy.
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
---
2+
description: Guidelines for improving the accessibility of a website to ensure it is usable for everyone, including people with disabilities.
3+
applyTo: "**/*.{html,css,js,jsx,ts,tsx,svelte,cshtml,php,vue,twig}"
4+
---
5+
6+
## Accessibility
7+
8+
Improving the accessibility of a website is essential to ensure it is usable for everyone, including people with disabilities. Here are additional guidelines to make your website more accessible:
9+
10+
### 1. Alt Text
11+
- Add meaningful `alt` text to all images. Make sure:
12+
- It is short and descriptive (≤125 characters).
13+
- Decorative images have an empty `alt` attribute (`alt=""`) so screen readers skip them.
14+
15+
**Example:**
16+
```html
17+
<img src="cat.jpg" alt="A black cat lying on a wooden chair." />
18+
<img src="decorative-line.png" alt="" />
19+
```
20+
21+
### 2. Color and Contrast
22+
- Ensure text has enough contrast against the background (≥4.5:1 for body text and ≥3:1 for large text).
23+
- Use tools like Contrast Checker to test this.
24+
- Avoid using color as the only way to convey information. Use text or symbols alongside colors.
25+
26+
Example (for visually impaired users):
27+
❌ Bad: "Click the green button to confirm."
28+
✅ Better: "Click the green button with the checkmark to confirm."
29+
30+
### 3. Logical DOM Order
31+
- Make sure content in the DOM is logically ordered so screen readers and keyboard navigation interpret it correctly.
32+
- Use landmarks like <header>, <main>, <nav>, and <footer> to help screen readers navigate.
33+
34+
Example:
35+
```html
36+
<header>...</header>
37+
<nav>...</nav>
38+
<main>...</main>
39+
<footer>...</footer>
40+
```
41+
42+
### 4. Focus Management and Keyboard Navigation
43+
- Test keyboard navigation in the browser:
44+
- Check if a user can navigate the entire page using the Tab key.
45+
- Correct use of tabindex:
46+
- Avoid positive tabindex values, as this creates an illogical tab order.
47+
- Use tabindex="0" to make an element focusable that is not focusable by default.
48+
- Use tabindex="-1" to make an element accessible via JavaScript without putting it in the tab order.
49+
50+
Example:
51+
```html
52+
<button tabindex="0">Confirm</button>
53+
<a href="#section" tabindex="0">Go to section</a>
54+
```
55+
56+
### 5. ARIA Attributes
57+
- Use ARIA (Accessible Rich Internet Applications) only when semantic HTML is not enough.
58+
- Avoid excessive use of ARIA; use HTML5 tags with built-in accessibility whenever possible.
59+
60+
ARIA Examples:
61+
- Use aria-label for buttons or links without text: `<button aria-label="Close">x</button>`
62+
- Use aria-expanded to indicate the state of a dropdown menu: `<button aria-expanded="false">Menu</button>`
63+
64+
### 6. Responsiveness and Assistive Technologies
65+
- Make sure the site works correctly on both desktop and mobile devices.
66+
- Check that the site works well with screen readers like NVDA, JAWS (Windows), and VoiceOver (macOS/iOS).
67+
- Test with different browsers: Chrome, Firefox, Safari.
68+
69+
### 7. Forms
70+
- Labels:
71+
- Add clear label elements to form fields:
72+
```html
73+
<label for="email">Email address</label>
74+
<input type="email" id="email" />
75+
```
76+
77+
- Accessible error messages:
78+
- Use clear error messages when a form is filled out incorrectly. Combine visual indicators (like red highlighted fields) with text.
79+
```html
80+
<span role="alert">Email address is required.</span>
81+
```
82+
83+
### 8. Text and Fonts
84+
- Use a minimum font size of 16px for base text.
85+
- Set line height to improve readability, for example 1.5.
86+
- Ensure text is scalable:
87+
- Avoid fixed px values and prefer em or rem units.
88+
89+
Example:
90+
```css
91+
body {
92+
font-size: 1rem; /* 16px base */
93+
line-height: 1.5;
94+
}
95+
```
96+
97+
### 9. Videos and Audio
98+
- Add subtitles to videos and text transcripts for audio.
99+
- Make sure videos have controls.
100+
- Use the aria-describedby attribute to provide alternative descriptions for complex media.
101+
102+
Example:
103+
```html
104+
<video controls aria-describedby="videodesc">
105+
<source src="sample-video.mp4" type="video/mp4" />
106+
</video>
107+
108+
<p id="videodesc">This video explains accessibility.</p>
109+
```
110+
111+
### 10. Keyboard Accessibility
112+
- Make sure interactive elements like buttons, links, and form fields have focus state styles:
113+
114+
```css
115+
button:focus, a:focus {
116+
outline: 2px solid #007bff;
117+
outline-offset: 2px;
118+
}
119+
```
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
applyTo: "**"
3+
---
4+
5+
6+
# Best Practices Instructions
7+
8+
Always apply these principles:
9+
- **SOLID**: Single responsibility, Open/closed, Liskov substitution, Interface segregation, Dependency inversion.
10+
- **DRY**: Don't Repeat Yourself; avoid duplication.
11+
- **KISS**: Keep It Simple, Stupid; prefer straightforward solutions.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
description: Coding standards and conventions for the project, including JavaScript/TypeScript, CSS, and component structure.
3+
applyTo: "**"
4+
---
5+
6+
## 🧑‍💻 Coding Standards & Conventions
7+
8+
### Coding Implementations
9+
10+
1. End every statement with a semicolon.
11+
2. Use single quotes for all string literals.
12+
3. Implement components as functions, not classes.
13+
4. Use arrow functions for all callbacks.
14+
5. Organize code by feature or module, keeping related files together.
15+
6. Write clear and concise JSDoc/TSDoc comments for functions, components, and modules.
16+
17+
## Code Guidelines
18+
- [CSS instructions](./css.instructions.md).
19+
- [JavaScript/TypeScript instructions](./javascript-typescript.instructions.md).
20+
- [Markdown instructions](./markdown.instructions.md).
21+
- [HTML instructions](./html.instructions.md).
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
description: Instructions for writing clear and consistent commit messages using the Conventional Commits format.
3+
applyTo: "**"
4+
tool: git
5+
---
6+
7+
# Commit Message Instructions
8+
9+
Writing clear and consistent commit messages is important for keeping the code history understandable and traceable. Follow the **Conventional Commits** format:
10+
11+
### **Commit Message Structure**
12+
13+
```
14+
<type>[scope]: <short description>
15+
```
16+
17+
- **`<type>`**: The type of change:
18+
- `feat`: New feature.
19+
- `fix`: Bug fix.
20+
- `docs`: Documentation changes.
21+
- `style`: Code formatting without functional changes.
22+
- `refactor`: Improvements to existing code without new features.
23+
- `test`: Adding or updating tests.
24+
- `chore`: Maintenance tasks, like dependency updates.
25+
26+
- **`[scope]`** *(optional)*: The component, module, or section you worked on.
27+
- **`<short description>`**: Briefly describe the change in present tense (max. 50-72 characters).
28+
29+
---
30+
31+
### **Commit Message Rules**
32+
1. **Concise and specific**: Use a maximum of 50-72 characters for the short description.
33+
2. **Present tense**: For example, "Add validation" instead of "Added validation".
34+
3. **No period at the end**: End the short description without a period.
35+
36+
---
37+
38+
### **Examples**
39+
#### New Feature
40+
```
41+
feat(header): add dropdown menu to navbar
42+
```
43+
#### Bug Fix
44+
```
45+
fix(api): resolve error when fetching user data
46+
```
47+
#### Documentation
48+
```
49+
docs(readme): add installation instructions
50+
```
51+
#### Refactor
52+
```
53+
refactor(utils): restructure formatting logic
54+
```
55+
#### Tests
56+
```
57+
test(auth): add tests for password recovery
58+
```
59+
#### Maintenance
60+
```
61+
chore(dependencies): update axios to v1.3.0
62+
```
63+
64+
With these guidelines, you write consistent commit messages that help keep the codebase maintainable.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
description: Instructions for configuration files used in the project, including .editorconfig, prettier, and eslint.
3+
applyTo: "**"
4+
---
5+
6+
# Configuration Files Instructions
7+
8+
- **.editorconfig**: Defines indentation, charset, line endings. Keep in project root.
9+
- **prettier.config.js** (frontend only): Enforce code formatting rules.
10+
Example:
11+
```js
12+
module.exports = {
13+
singleQuote: true,
14+
trailingComma: 'all',
15+
printWidth: 100,
16+
};
17+
```
18+
- **.eslintrc.js**: Enforce consistent linting rules.
19+
Example:
20+
```js
21+
module.exports = {
22+
env: {
23+
browser: true,
24+
node: true,
25+
es6: true,
26+
},
27+
extends: [
28+
'@sbb-configs/shared-eslint'
29+
],
30+
parserOptions: {
31+
ecmaVersion: 2020,
32+
sourceType: 'module',
33+
},
34+
rules: {
35+
// add project-specific overrides here
36+
},
37+
};
38+
```

0 commit comments

Comments
 (0)