Skip to content

Commit b527b1f

Browse files
authored
Add copilot instructions
1 parent fe7ed26 commit b527b1f

1 file changed

Lines changed: 239 additions & 0 deletions

File tree

.github/copilot-instructions.md

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
# Instructions
2+
3+
## Project contribution guidelines
4+
5+
- [ ] Follow the project's established coding style and conventions.
6+
- [ ] Run Ruff and fix errors before committing code.
7+
- [ ] New code should be written to pass all Ruff checks.
8+
- [ ] McCabe complexity should be kept low; refactor the new code
9+
that exceeds 10.
10+
- [ ] Existing code should be gradually improved to pass Ruff checks
11+
when making changes.
12+
- [ ] Write clear and concise commit messages that accurately describe
13+
the changes made.
14+
- [ ] For significant changes, update the CHANGELOG.md file
15+
to document the changes.
16+
- [ ] Follow "Keep a Changelog" principles
17+
https://keepachangelog.com/en/1.0.0/
18+
- [ ] Use semantic versioning for version numbers
19+
https://semver.org/
20+
- [ ] If it is a breaking change, indicate it clearly in the changelog.
21+
- [ ] Provide migration instructions if necessary.
22+
- [ ] Do not leave trailing whitespaces in the code or documentation files,
23+
unless such a whitespace is explicitly necessary.
24+
- [ ] Metadata in pyproject.toml, codemeta.json, CITATION.cff, and other
25+
project metadata files should be consistent and up-to-date.
26+
- [ ] Project name
27+
- [ ] Project version
28+
- [ ] Author/contributor names
29+
- [ ] License information
30+
- [ ] Project description
31+
- [ ] Repository URL
32+
- [ ] Keywords/tags (in the same order if possible)
33+
34+
## General language use
35+
36+
- [ ] Write short and simple comments. Do not state the obvious.
37+
- [ ] Prefer clear, concise, and unambiguous sentences.
38+
- [ ] Do not use jargon, slang, or idiomatic expressions
39+
that may not be universally understood.
40+
- [ ] Use active voice whenever possible.
41+
- [ ] Use consistent terminology throughout the code and documentation.
42+
- [ ] Define acronyms and abbreviations on their first use.
43+
- [ ] Use technical terms accurately and appropriately.
44+
- [ ] Avoid unnecessary complexity and verbosity.
45+
- [ ] Use proper grammar, punctuation, and spelling.
46+
- [ ] Use consistent formatting for dates, times, numbers, and units of measure.
47+
- [ ] When using abbreviations for units of measure, follow the International
48+
System of Units (SI) conventions.
49+
- [ ] When using code snippets, ensure they are properly formatted and
50+
follow the conventions of the programming language being used.
51+
- [ ] Avoid words and phrases that may have more than one interpretation.
52+
- [ ] Avoid overly long paragraphs. Breaking up text into smaller paragraphs,
53+
using bullet points, or creating numbered lists to improve readability.
54+
- [ ] Help readers' comprehension by separating distinct concepts, processes,
55+
criteria, or categories.
56+
- [ ] Use parallel language structures in lists and documentation.
57+
- [ ] Use a uniform writing style, particularly when presenting similar or
58+
related information, so the reader can compare easily.
59+
- [ ] If not specified otherwise, use Chicago style for reference/citation.
60+
- [ ] When writing on level of requirements, use the verbal forms consistently.
61+
Use either ISO/IEC verbal form (ISO/IEC Directives, Part 2 --
62+
Principles and rules for the structure and drafting of ISO and IEC
63+
documents) or IETF verbal form (RFC 2119 and RFC 8174).
64+
Try to detect the level of requirements from type/domain of the document.
65+
IETF is default for internet/web/semantic web projects in general.
66+
ISO is default for SPDX project.
67+
- [ ] Use American English spelling consistently.
68+
69+
## Naming conventions
70+
71+
- [ ] Follow standard naming conventions for the programming language
72+
and framework you are using.
73+
- [ ] Use only ASCII letters, digits, hyphen (-), and underscore (_)
74+
in names.
75+
- [ ] For URLs/IRIs, use lowercase letters and hyphens to separate words
76+
(e.g., `my-api-endpoint`) and follow W3C Cool URIs for the Semantic Web:
77+
https://www.w3.org/TR/cooluris/
78+
- [ ] Consult Schema.org vocabularies when deciding about names.
79+
- [ ] Consult "Style Guidelines for Naming and Labeling Ontologies in the
80+
Multilingual Web" https://www.researchgate.net/publication/277224472
81+
82+
## Tidy code and documentation
83+
84+
- [ ] Ensure that the code is well-formatted and adheres to the style
85+
guidelines of the programming language you are using.
86+
- [ ] Use linters and formatters where applicable.
87+
- [ ] Use "sentence case" for headings and titles in documentation.
88+
- [ ] Write clear and concise comments and documentation for your code.
89+
For something obvious, avoid comments that just restate the code.
90+
- [ ] After making changes, review the code and documentation to ensure
91+
up-to-dateness, correctness, consistency, and clarity.
92+
- [ ] Make sure that all code comments, APIs, and documentation are consistent
93+
with the current state of the codebase.
94+
- [ ] Make sure that the examples in the documentation are runnable, up-to-date
95+
and reflect the current behavior of the code.
96+
97+
## File header
98+
99+
- [ ] When possible, put relevant SPDX File Tags at file header.
100+
See https://spdx.github.io/spdx-spec/v2.3/file-information/
101+
- [ ] SPDX-FileContributor
102+
- [ ] SPDX-FileCopyrightText
103+
- [ ] Default SPDX-FileType for code is "SOURCE"
104+
- [ ] Default SPDX-FileType for documentation is "DOCUMENTATION"
105+
- [ ] Default SPDX-License-Identifier for code is "Apache-2.0"
106+
- [ ] Default SPDX-License-Identifier for documentation is "CC0-1.0"
107+
- [ ] Sort SPDX metadata.
108+
109+
## Shell scripts and command line
110+
111+
- [ ] Mind the differences between GNU, BSD, macOS,
112+
and other implementations of common Unix tools.
113+
- [ ] Be defensive on variable expansion.
114+
- [ ] Use quotes or other constructs to encapsulate paths, make it compatible
115+
with different kinds of shells.
116+
- [ ] Be mindful about the semantics of different types of quotation marks.
117+
118+
## Library imports and dependencies
119+
120+
- [ ] Check the correctness of library/module/package names.
121+
Be very careful of slopsquatting and typosquatting attacks.
122+
- [ ] Use the most updated version of the library that is supported
123+
by the OS/compiler/framework currently being used.
124+
- [ ] In source code, group and sort imports by the programming language
125+
convention (e.g., in Python, typically by standard library first,
126+
then by third-party libraries)
127+
and then by alphabetical order whenever possible.
128+
Be careful of specific order of import requirements of some dependencies,
129+
as moving the order may break the code or create cyclic import issues.
130+
- [ ] Remove unused imports.
131+
- [ ] In build metadata (like pyproject.toml in Python) or
132+
dependency list (like requirements.txt in Python), sort dependencies.
133+
- [ ] Warn users about abandoned dependencies with no maintenance
134+
for a long time and suggest equivalent drop-in replacements.
135+
136+
## Security
137+
138+
- [ ] Avoid using deprecated, obsolete, or insecure libraries,
139+
frameworks, or APIs.
140+
- [ ] When handling sensitive data (like passwords, API keys, personal data),
141+
follow best practices for data protection and privacy.
142+
- [ ] Avoid hardcoding sensitive information (like passwords, API keys)
143+
directly in the codebase.
144+
- [ ] Validate and sanitize all user inputs to prevent security vulnerabilities
145+
such as SQL injection, cross-site scripting (XSS), and buffer overflows.
146+
- [ ] Regularly update dependencies to their latest secure versions.
147+
- [ ] When suggesting code that involves cryptography,
148+
use strong and well-established algorithms and key sizes.
149+
- [ ] When dealing with authentication and authorization,
150+
follow best practices and standards like OAuth2, OpenID Connect, etc.
151+
- [ ] Avoid using eval() and similar functions that execute arbitrary code,
152+
unless absolutely necessary and safe.
153+
- [ ] Avoid the deserialization of untrusted data (CWE-502).
154+
- [ ] In Python, avoid using `pickle` module for
155+
serialization/deserialization.
156+
- [ ] When handling files and paths, be careful of path traversal vulnerabilities
157+
like CWE-22.
158+
159+
## API
160+
161+
- [ ] The overall architecture, code, and API endpoints should follow the latest
162+
version of OpenAPI specification at https://spec.openapis.org/oas/
163+
- [ ] API endpoints must use proper HTTP return codes.
164+
- [ ] Follow web best practices as recommended by OpenAPI, IETF, W3C, etc.
165+
166+
## Python
167+
168+
- [ ] Defensive coding: always check for None/empty and handle exceptions
169+
when dealing with external inputs, like function arguments,
170+
file I/O, network I/O, etc.
171+
- [ ] Use type hints for function/method signatures
172+
and variable declarations as much as possible.
173+
- [ ] requires-python in pyproject.toml should reflect the minimum
174+
Python version supported by the project.
175+
- [ ] Do not introduce syntax or features that are not supported
176+
by the specified minimum Python version,
177+
unless it is supported via `__future__` imports.
178+
- [ ] Do not use | union type syntax if minimum Python version is
179+
below 3.10.
180+
- [ ] Make sure that the module/class/function/object can be properly used by
181+
runtime type inspection tools, documentation generators, and static
182+
analysis tools.
183+
For example, typing.get_type_hints() should work properly.
184+
- [ ] Do not use mutable default arguments in function/method definitions.
185+
- [ ] Do not use wildcard imports (from module import *).
186+
- [ ] Remove any trailing whitespace in the Python file.
187+
- [ ] Make the package zip-safe if possible.
188+
- [ ] Be mindful about choice of data structures.
189+
Prefer built-in data structures like list, dict, set, and tuple
190+
unless there is a specific need for specialized data structures.
191+
If specialized data structures are needed, consider using
192+
appropriate collection types from `collections` and
193+
`collections.abc` modules.
194+
Use the most appropriate data structure for the specific use case
195+
to optimize performance and memory usage.
196+
197+
## JSON
198+
199+
- [ ] When serialize to JSON, always enclose decimal values
200+
(for example, xs:decimal) in quotes to guarantee correct type
201+
interpretation and preserve precision.
202+
- [ ] Make sure JSON is valid and well-formatted.
203+
204+
## Markdown
205+
206+
- [ ] When including metadata in Markdown file,
207+
put them as YAML between triple-dashed lines,
208+
as used by Hugo and Jekyll front matter.
209+
- [ ] Be strict on the Markdown formatting.
210+
Be mindful that what works on GitHub may not work on MkDocs, for example.
211+
Try to keep with the standard Markdown.
212+
- [ ] Use Markdownlint to detect and fix malformatted.
213+
214+
## Diagram
215+
216+
- [ ] When draw the diagram in ASCII/text, recheck if all the lines are well
217+
aligned.
218+
Count the characters and adjust the spaces so the lines align well.
219+
220+
## HTML
221+
222+
- [ ] Make sure HTML is valid and well-formatted.
223+
- [ ] Make sure there is no trailing whitespace in the HTML file.
224+
- [ ] Be conscious about accessibility. Consider to follow W3C web
225+
accessibility recommendations when possible.
226+
- [ ] Use sensible and concise element IDs and names that allow code
227+
readability, name grouping also helps.
228+
229+
## CSS
230+
231+
- [ ] Make sure there is no unused styles.
232+
- [ ] Use sensible and concise element IDs and names that allow code
233+
readability, name grouping also helps.
234+
235+
## Version
236+
237+
- [ ] When suggest dependencies, recheck the version; if the version exists,
238+
or if the version is compatible with the system or other dependencies.
239+
- [ ] Prefer a Semantic Version when applicable.

0 commit comments

Comments
 (0)