agentleFS
giffletgifflet/cursor-like-pro/.cursor/rules/git-conventions.mdc

cursor-like-pro / rules

Cursor rule17 starsChanged 20 months agoMITView on GitHub

Git conventions and workflow guidelines using Conventional Commits

  • Commits and pushes
  • Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.

    Of the Cursor rule files we read, the 1,533 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository2 other files it gives its agents.

The file

Show its rules and text

We split this git-conventions.mdc into the rules it gives an agent

37 rules. About 0 are common, 35 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈35

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    All git-related text MUST be written in English:

    line 10
  2. Distinctive:

    All commit messages MUST follow the Conventional Commits specification:

    line 19
  3. Distinctive:

    Use the imperative, present tense: "change" not "changed" nor "changes"

    line 50
  4. Distinctive:

    Don't capitalize first letter

    line 51
  5. Distinctive:

    No dot (.) at the end

    line 52
  6. Distinctive:

    All changes must come through Pull Requests

    line 79
  7. Distinctive:

    Create PR from feature branch to main/master

    line 102
  8. Distinctive:

    Use PR template if available

    line 103
  9. Distinctive:

    All tests must pass

    line 105
  10. Distinctive:

    Consider using pre-commit hooks to enforce these conventions:

    line 146
  11. Distinctive:

    Commit message format validation

    line 147
  12. Distinctive:

    Always create a feature branch first

    line 246
  13. Distinctive:

    Use Pull Requests for merging changes

    line 247
  14. Distinctive:

    Follow type/description format for branches

    line 259
  15. Distinctive:

    Follow conventional commits for messages

    line 260
  16. Distinctive:

    Keep descriptions clear and concise

    line 261
  17. Distinctive:

    When using MCP Git with our recommended tools:

    line 265
  18. Distinctive:

    Branch Protection: Ensure your repository has branch protection rules enabled for main/master

    line 270
  19. Distinctive:

    When working with MCP Git operations, follow these guidelines for path handling:

    line 277
  20. Distinctive:

    Use normalized Windows paths (backslashes)

    line 280
  21. Distinctive:

    Remove URL encoding from paths

    line 281
  22. Distinctive:

    Remove duplicate drive letters

    line 282
  23. Distinctive:

    Always normalize paths before passing to MCP Git functions

    line 311
  24. Distinctive:

    Use consistent path separators (Windows style for Windows)

    line 312
  25. Distinctive:

    Remove any URL encoding artifacts

    line 314
  26. Very specific:

    When using any MCP Git command, the repo_path parameter MUST follow these exact rules:

    line 337
  27. Distinctive:

    Use forward slashes (/) instead of backslashes (\)

    line 352
  28. Distinctive:

    Start with drive letter (e.g., C:/)

    line 353
  29. Distinctive:

    NO URL encoding (%3A)

    line 354
  30. Distinctive:

    NO duplicate drive letters

    line 355
  31. Distinctive:

    NO leading slashes before drive letter

    line 356
  32. Distinctive:

    When using MCP Git with other tools or systems:

    line 372
  33. Distinctive:

    Ensure path normalization before passing to MCP Git

    line 375
  34. Very specific:

    Use os.path functions for path manipulation

    line 379
  35. Distinctive:

    Consider platform-specific path separators

    line 380
  36. Distinctive:

    Keep path handling consistent across commits

    line 383
  37. Distinctive:

    Document path handling requirements

    line 384

≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
git-conventions.mdc
---
description: Git conventions and workflow guidelines using Conventional Commits
globs: 
alwaysApply: false
---
# Git Conventions and Workflow Guidelines 🔄

## Language Requirements

All git-related text MUST be written in English:
- Commit messages
- Branch names
- Pull request titles and descriptions
- Code review comments
- Issue titles and descriptions

## Commit Message Format

All commit messages MUST follow the [Conventional Commits](mdc:https:/www.conventionalcommits.org) specification:

```
<type>[optional scope]: <description>

[optional body]

[optional footer(s)]
```

### Types

- `feat`: A new feature
- `fix`: A bug fix
- `docs`: Documentation only changes
- `style`: Changes that do not affect the meaning of the code (formatting, etc)
- `refactor`: A code change that neither fixes a bug nor adds a feature
- `perf`: A code change that improves performance
- `test`: Adding missing tests or correcting existing tests
- `chore`: Changes to the build process or auxiliary tools
- `ci`: Changes to CI configuration files and scripts

### Scope
The scope should be the name of the component affected (as perceived by the person reading the changelog).

Examples:
- `feat(auth): add login with Google`
- `fix(api): handle null response from server`
- `docs(readme): update installation steps`

### Description
- Use the imperative, present tense: "change" not "changed" nor "changes"
- Don't capitalize first letter
- No dot (.) at the end
- Write in english

## Branch Naming Convention

Branches should follow this pattern:
```
<type>/<short-description>
```

For features and fixes that are tracked in a project management system, include the ticket number:
```
<type>/<ticket-number>-<short-description>
```

Examples:
- `feat/add-google-auth`
- `fix/handle-null-responses`
- `docs/update-readme`
- `feat/PROJ-123-add-google-auth`
- `fix/PROJ-456-handle-null-responses`

## Workflow Guidelines

1. **Protected Branches**
   - `main` (or `master`): Production-ready code, protected branch
   - Direct commits to protected branches are NOT allowed
   - All changes must come through Pull Requests

2. **Feature Development**
   ```bash
   # First, check if you're on a protected branch
   git branch --show-current
   
   # If on main/master, create and checkout a new feature branch
   git checkout -b feat/my-new-feature main
   
   # Make changes and commit
   git add .
   git commit -m "feat(scope): add new feature"
   
   # Keep branch updated with main
   git fetch origin main
   git rebase origin/main
   
   # Push changes
   git push origin feat/my-new-feature
   ```

3. **Pull Request Process**
   - Create PR from feature branch to main/master
   - Use PR template if available
   - Request at least 2 code reviews
   - All tests must pass
   - No merge conflicts
   - Squash commits when merging

4. **Release Process**
   ```bash
   # Create release branch from main
   git checkout main
   git pull origin main
   git checkout -b release/v1.0.0
   
   # After testing, merge back to main via PR
   # After PR is approved and merged:
   git checkout main
   git pull origin main
   git tag -a v1.0.0 -m "version 1.0.0"
   git push origin main --tags
   ```

## Examples

✅ Good Commits:
```bash
feat(auth): implement JWT authentication
fix(api): handle edge case in user validation
docs(api): update API documentation
style(components): format according to style guide
refactor(database): optimize query performance
test(auth): add unit tests for login flow
```

❌ Bad Commits:
```bash
Fixed stuff
Updated code
WIP
Quick fix
```

## Pre-commit Hooks

Consider using pre-commit hooks to enforce these conventions:
- Commit message format validation
- Code linting
- Test execution
- Branch naming validation
- Protected branch validation

## Using MCP Git in Cursor 🤖

The Model Context Protocol (MCP) Git integration allows you to perform Git operations directly from Cursor while following our commit conventions.

> **Important**: For proper path handling in MCP Git operations, please refer to the `mcp-git-path-encoding.mdc` rule file. This ensures consistent path handling across different platforms and prevents encoding issues.

### Basic MCP Git Commands

1. **Check Current Branch and Create Feature Branch if Needed**
   ```python
   # First check current branch
   mcp_git_git_status(repo_path=".")
   
   # If on main/master, create and switch to feature branch
   mcp_git_git_create_branch(
       repo_path=".",
       branch_name="feat/my-new-feature",
       base_branch="main"
   )
   mcp_git_git_checkout(
       repo_path=".",
       branch_name="feat/my-new-feature"
   )
   ```

2. **Viewing Changes**
   ```python
   # View unstaged changes
   mcp_git_git_diff_unstaged(repo_path=".")
   
   # View staged changes
   mcp_git_git_diff_staged(repo_path=".")
   ```

3. **Making Commits**
   ```python
   # First ensure you're not on a protected branch
   status = mcp_git_git_status(repo_path=".")
   if "main" in status or "master" in status:
       # Create feature branch first
       branch_name = "feat/my-feature"
       mcp_git_git_create_branch(
           repo_path=".",
           branch_name=branch_name,
           base_branch="main"
       )
       mcp_git_git_checkout(repo_path=".", branch_name=branch_name)
   
   # Then stage and commit
   mcp_git_git_add(repo_path=".", files=["path/to/file"])
   mcp_git_git_commit(
       repo_path=".",
       message="feat(component): add new feature"
   )
   ```

### MCP Git Workflow Example

```python
# 1. Check current branch
mcp_git_git_status(repo_path=".")

# 2. If on main/master, create feature branch
mcp_git_git_create_branch(
    repo_path=".",
    branch_name="feat/user-auth",
    base_branch="main"
)
mcp_git_git_checkout(
    repo_path=".",
    branch_name="feat/user-auth"
)

# 3. Make changes and commit
mcp_git_git_add(repo_path=".", files=["src/auth/*"])
mcp_git_git_commit(
    repo_path=".",
    message="feat(auth): implement user authentication"
)

# 4. View commit history
mcp_git_git_log(repo_path=".", max_count=5)
```

### Best Practices for MCP Git

1. **Always Check Branch First**
   ```python
   # Check current branch before any operations
   mcp_git_git_status(repo_path=".")
   ```

2. **Never Commit Directly to Protected Branches**
   - Always create a feature branch first
   - Use Pull Requests for merging changes

3. **Review Changes Before Committing**
   ```python
   # Review unstaged changes
   mcp_git_git_diff_unstaged(repo_path=".")
   
   # Review staged changes
   mcp_git_git_diff_staged(repo_path=".")
   ```

4. **Use Meaningful Branch Names and Commit Messages**
   - Follow type/description format for branches
   - Follow conventional commits for messages
   - Keep descriptions clear and concise

### Integration with Development Tools

When using MCP Git with our recommended tools:

1. **Commitlint**: MCP Git commits will be validated against our commit conventions
2. **Husky**: Pre-commit hooks will run on MCP Git commits
3. **CI/CD**: MCP Git commits trigger the same workflows as regular Git commits
4. **Branch Protection**: Ensure your repository has branch protection rules enabled for main/master


# MCP Git Path Encoding Guidelines 🛠️

## Path Handling in MCP Git Operations

When working with MCP Git operations, follow these guidelines for path handling:

1. **Path Format**
   - Use normalized Windows paths (backslashes)
   - Remove URL encoding from paths
   - Remove duplicate drive letters

2. **Path Transformation**
   ```python
   # Instead of using raw workspace path
   repo_path = "/c%3A/Users/path/to/repo"  # ❌ Wrong

   # Transform the path before using
   import os
   
   def normalize_path(path):
       # Remove URL encoding
       path = path.replace("%3A", ":")
       # Convert to Windows path format
       path = path.replace("/", "\\")
       # Remove leading slashes and handle drive letter properly
       if ":" in path:
           # Split on drive letter colon
           parts = path.split(":", 1)
           drive = parts[0].strip("\\")  # Remove any leading slashes
           remaining = parts[1]
           path = f"{drive}:{remaining}"
       return path

   repo_path = normalize_path("/Users/path/to/repo")  # ✅ Correct
   # Result: c:\Users\path\to\repo
   ```

3. **Best Practices**
   - Always normalize paths before passing to MCP Git functions
   - Use consistent path separators (Windows style for Windows)
   - Handle drive letter properly
   - Remove any URL encoding artifacts

4. **Example Usage**
   ```python
   # Before any MCP Git operation
   repo_path = normalize_path(workspace_path)
   
   # Then use in MCP Git commands
   mcp_git_git_status(repo_path=repo_path)
   mcp_git_git_add(repo_path=repo_path, files=["file.txt"])
   mcp_git_git_commit(repo_path=repo_path, message="feat: add new feature")
   ```

5. **Common Issues to Avoid**
   - Using paths with URL encoding (e.g. %3A)
   - Using paths that start with / or \\ before the drive letter
   - Mixing forward and backward slashes
   - Using paths with improper encoding

## Critical Path Format Requirements for MCP Git

### Repo Path Format Specification

When using any MCP Git command, the `repo_path` parameter MUST follow these exact rules:

1. **Correct Format**
   ```
   C:/Users/path/to/repo    ✅ Correct
   ```

2. **Forbidden Formats**
   ```
   /c%3A/Users/path/to/repo     ❌ Wrong (URL encoded)
   C:\c%3A\Users\path\to\repo   ❌ Wrong (Duplicated drive)
   \c%3A\Users\path\to\repo     ❌ Wrong (Leading slash + encoding)
   ```

3. **Rules**
   - Use forward slashes (/) instead of backslashes (\)
   - Start with drive letter (e.g., C:/)
   - NO URL encoding (%3A)
   - NO duplicate drive letters
   - NO leading slashes before drive letter
   - Path must be absolute

4. **Example Usage in MCP Git Commands**
   ```python
   # Correct usage
   mcp_git_git_log(repo_path="C:/Users/path/to/repo")
   mcp_git_git_status(repo_path="C:/Users/path/to/repo")
   mcp_git_git_commit(repo_path="C:/Users/path/to/repo", message="feat: add feature")
   ```

> **IMPORTANT**: Failure to follow this exact format will result in path resolution errors and incorrect Git operations.


## Integration with Other Tools

When using MCP Git with other tools or systems:

1. **IDE Integration**
   - Ensure path normalization before passing to MCP Git
   - Handle workspace paths consistently

2. **Cross-platform Compatibility**
   - Use `os.path` functions for path manipulation
   - Consider platform-specific path separators

3. **Version Control**
   - Keep path handling consistent across commits
   - Document path handling requirements

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.