Skip to content

Commit 936399a

Browse files
Introduce Cursor rules to improve quality of AI (#4445)
This PR introduces instructions for the AI when working with Cursor. --------- Co-authored-by: Falko Schindler <[email protected]>
1 parent 8ae5140 commit 936399a

File tree

4 files changed

+51
-0
lines changed

4 files changed

+51
-0
lines changed

.cursor/rules/coding.mdc

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
description: writing code
3+
globs: *.py
4+
alwaysApply: false
5+
---
6+
# Coding Style
7+
8+
- Always prefer simple solutions
9+
- Avoid having files over 200-300 lines of code. Refactor at that point
10+
- Use single quotes for strings in Python
11+
- Use f-strings wherever possible for better readability (except in performance-critical sections which should be marked with "NOTE:" comments)
12+
- Follow autopep8 formatting with 120 character line length
13+
- Each sentence in documentation should be on a new line
14+
- Use ruff for linting and code checks
15+
16+
# Workflow
17+
18+
- Never overwrite .env file without first asking and confirming
19+
- Avoid duplication of code whenever possible, which means checking for other areas of the codebase that might already have similar code and functionality
20+
- Be careful to only make changes that are requested or are well understood and related to the change being requested
21+
- When fixing an issue or bug, do not introduce a new pattern or technology without first exhausting all options for the existing implementation. And if you finally do this, make sure to remove the old implementation afterwards so we don't have duplicate logic
22+
- Keep the codebase very clean and organized
23+
- Write tests for new features
24+
- Run tests before submitting any changes
25+
- Format code using autopep8 before submitting changes
26+
- Use pre-commit hooks to ensure coding style compliance
27+
- When adding new features, include corresponding tests
28+
- For documentation changes, ensure each sentence is on a new line

.cursor/rules/general.mdc

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
description: General overview and context
3+
globs:
4+
alwaysApply: true
5+
---
6+
# Project Description
7+
8+
This is the official NiceGUI repository. With NiceGUI you can write graphical user interfaces which run in the browser. It has a very gentle learning curve while still offering the option for advanced customizations. NiceGUI follows a backend-first philosophy: it handles all the web development details for the developer, so they can focus on writing Python code. This makes it ideal for a wide range of projects including short scripts, dashboards, robotics projects, IoT solutions, smart home automation, and machine learning.
9+
10+
# Technical Stack
11+
12+
- Python/FastAPI for the backend
13+
- Vue/Quasar in the frontend
14+
- socket.io for communication between frontend and backend
15+
16+
# Design Decisions
17+
18+
- All user interactions are send to the backend and invoke the proper Python functions.
19+
- Unlike Streamlit the framework took much care to allow easy integration with any other Python libraries.
20+
- NiceGUI only uses one uvicorn worker (to not have to implement/support tricky synchronization).
21+
- The socket.io library is used for managing web sockets. After the initial content is loaded a web socket connection is established and kept open for communication as long as the web page is shown.

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ demo.py
1919
tests/.pytest_cache/**/*
2020
**/.ruff_cache
2121
**/*.pyc
22+
**/.cursor
2223
**/.DS_Store
2324
**/.idea
2425
**/.vscode

.syncignore

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ venv
1010
.idea
1111
.nicegui/
1212
*.sqlite*
13+
.cursor/
1314
.DS_Store
1415
.pytest_cache/
1516
.vscode/

0 commit comments

Comments
 (0)