Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Cursor rules to improve quality of AI #4445

Merged
merged 2 commits into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .cursor/rules/coding.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
description: writing code
globs: *.py
alwaysApply: false
---
# Coding Style

- Always prefer simple solutions
- Avoid having files over 200-300 lines of code. Refactor at that point
- Use single quotes for strings in Python
- Use f-strings wherever possible for better readability (except in performance-critical sections which should be marked with "NOTE:" comments)
- Follow autopep8 formatting with 120 character line length
- Each sentence in documentation should be on a new line
- Use ruff for linting and code checks

# Workflow

- Never overwrite .env file without first asking and confirming
- Avoid duplication of code whenever possible, which means checking for other areas of the codebase that might already have similar code and functionality
- Be careful to only make changes that are requested or are well understood and related to the change being requested
- 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
- Keep the codebase very clean and organized
- Write tests for new features
- Run tests before submitting any changes
- Format code using autopep8 before submitting changes
- Use pre-commit hooks to ensure coding style compliance
- When adding new features, include corresponding tests
- For documentation changes, ensure each sentence is on a new line
21 changes: 21 additions & 0 deletions .cursor/rules/general.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
description: General overview and context
globs:
alwaysApply: true
---
# Project Description

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.

# Technical Stack

- Python/FastAPI for the backend
- Vue/Quasar in the frontend
- socket.io for communication between frontend and backend

# Design Decisions

- All user interactions are send to the backend and invoke the proper Python functions.
- Unlike Streamlit the framework took much care to allow easy integration with any other Python libraries.
- NiceGUI only uses one uvicorn worker (to not have to implement/support tricky synchronization).
- 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.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ demo.py
tests/.pytest_cache/**/*
**/.ruff_cache
**/*.pyc
**/.cursor
**/.DS_Store
**/.idea
**/.vscode
1 change: 1 addition & 0 deletions .syncignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ venv
.idea
.nicegui/
*.sqlite*
.cursor/
.DS_Store
.pytest_cache/
.vscode/
Expand Down