Skip to content

Cursor rules: Add Cursor Rules for Development and Git Commit Standards #575

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

Merged
merged 2 commits into from
Feb 23, 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
37 changes: 37 additions & 0 deletions .cursor/rules/dev-loop.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
description: QA every edit
globs: *.py
---

# First: QA Every edit

Run these commands between edits:

Check typings:

```
uv run mypy
```

Lint:

```
uv run ruff check . --fix; uv run ruff format .;
```

Check tests:

```
uv run py.test
```

Between every edit, rerun:
- Type checks
- Lint
- Tests

If there's any failures *due to the edits*, fix them first, then:

# When your edit is complete: Commit it

Make an atomic commit for the edit, using conventional commits.
82 changes: 82 additions & 0 deletions .cursor/rules/git-commits.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
description: git-commits: Git commit message standards and AI assistance
globs: git-commits: Git commit message standards and AI assistance | *.git/* .gitignore .github/* CHANGELOG.md CHANGES.md
---
# Git Commit Standards

## Format
```
type(scope[component]): concise description

why: explanation of necessity/impact
what:
- technical changes made
- keep focused on single topic

refs: #issue-number, breaking changes, links
```

## Commit Types
- `feat`: New features/enhancements
- `fix`: Bug fixes
- `refactor`: Code restructuring
- `docs`: Documentation changes
- `chore`: Maintenance tasks (deps, tooling)
- `test`: Test-related changes
- `style`: Code style/formatting

## Guidelines
- Subject line: max 50 chars
- Body lines: max 72 chars
- Use imperative mood ("Add" not "Added")
- Single topic per commit
- Blank line between subject and body
- Mark breaking changes with "BREAKING:"
- Use "See also:" for external links

## AI Assistance in Cursor
- Stage changes with `git add`
- Use `@commit` to generate initial message
- Review and adjust the generated message
- Ensure it follows format above

## Examples

Good commit:
```
feat(subprocess[run]): Switch to unicode-only text handling

why: Improve consistency and type safety in subprocess handling
what:
- BREAKING: Changed run() to use text=True by default
- Removed console_to_str() helper and encoding logic
- Simplified output handling
- Updated type hints for better safety

refs: #485
See also: https://docs.python.org/3/library/subprocess.html
```

Bad commit:
```
updated some stuff and fixed bugs
```

Cursor Rules: Add development QA and git commit standards (#cursor-rules)

- Add dev-loop.mdc: QA process for code edits
- Type checking with mypy
- Linting with ruff
- Test validation with pytest
- Ensures edits are validated before commits

- Add git-commits.mdc: Commit message standards
- Structured format with why/what sections
- Defined commit types and guidelines
- Examples of good/bad commits
- AI assistance instructions

Note: These rules help maintain code quality and commit history
consistency across the project.

See also: https://docs.cursor.com/context/rules-for-ai