agentleFS
metagit-aimetagit-ai/metagit-cli/.cursor/rules/project-level.mdc

metagit-cli / rules

Cursor rule4 starsChanged 11 days agoMITView on GitHub

Metagit

  • Reads credentials

The file

Show its rules and text

We split this project-level.mdc into the rules it gives an agent

37 rules. About 0 are common, 26 are distinctive, and 11 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈26

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 11

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Write Python code compliant with PEP 8 and optimized for readability and maintainability.

    line 11
  2. Distinctive:

    Use type hints for all function parameters and return types.

    line 12
  3. Distinctive:

    Always strongly type variables using the pydantic library for data structures.

    line 13
  4. Distinctive:

    Always use Protocol definitions for interface definitions.

    line 14
  5. Distinctive:

    Avoid duplication by using clear, modular code organization.

    line 16
  6. Distinctive:

    All file paths should be constructed using os.path.join() instead of string concatenation.

    line 17
  7. Distinctive:

    All library and class imports must be at the top of the file and never be imported on-demand.

    line 18
  8. Distinctive:

    Remove all unused imports from each python file after editing them.

    line 19
  9. Distinctive:

    Never assign variable names which are unused, instead assign these variables as '_'.

    line 20
  10. Very specific:

    Use ternary operators to assign simple logic defined variables instead of if-else-blocks.

    line 23
  11. Distinctive:

    Use 2 spaces for indentation.

    line 25
  12. Very specific:

    Use isinstance() for type comparisons.

    line 27
  13. Distinctive:

    Use snake_case for variables, functions, and filenames.

    line 31
  14. Distinctive:

    Use PascalCase for class names.

    line 32
  15. Very specific:

    Use descriptive names for configuration files (e.g., agents.yaml, tasks.yaml).

    line 34
  16. Very specific:

    Use python-dotenv to manage environment variables.

    line 38
  17. Very specific:

    Use yaml.safe_load for security.

    line 41
  18. Distinctive:

    Follow Pythonic idioms and best practices.

    line 48
  19. Distinctive:

    Use early returns in functions to simplify logic.

    line 49
  20. Distinctive:

    Write clear docstrings for all classes and functions.

    line 50
  21. Distinctive:

    Use try-except blocks with meaningful error messages.

    line 55
  22. Distinctive:

    Never create bare exception statements.

    line 56
  23. Distinctive:

    Ensure secure loading of configuration files.

    line 59
  24. Distinctive:

    All functions and methods that produce exceptions should return a union of the expected result type and Exception and be handled …

    line 60
  25. Distinctive:

    Avoid introducing new external dependencies unless absolutely necessary.

    line 64
  26. Distinctive:

    If a new dependency is required, please state the reason.

    line 65
  27. Distinctive:

    Never hardcode sensitive data.

    line 69
  28. Very specific:

    Keep API keys and sensitive data in .env (gitignored).

    line 70
  29. Distinctive:

    Document code with clear inline comments.

    line 79
  30. Distinctive:

    Keep CHANGELOG.md updated with all changes.

    line 80
  31. Very specific:

    Use the gh command-line to interact with GitHub.

    line 94
  32. Very specific:

    Use the glow command-line to present markdown content.

    line 97
  33. Very specific:

    Use the jq command to read and extract information from JSON files.

    line 100
  34. Very specific:

    Use npx for running commands directly from npm packages.

    line 117
  35. Very specific:

    Always last: run task gitnexus:analyze from the repository root so the GitNexus knowledge graph index stays fresh for MCP navigation and …

    line 122
  36. Distinctive:

    If working with a new library or tool, consider looking for its documentation from its website, GitHub project, or the relevant llms.txt.

    line 125
  37. Distinctive:

    If you find a relevant llms.txt file, follow the links until you have access to the complete documentation.

    line 130

≈ “Common” is an estimate: at least 1 in 5 of the 6,668 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
project-level.mdc
---
description: Metagit
globs: *
alwaysApply: true
---

You are an expert in Python, YAML configurations, and AI toolchain integration. Your role is to assist developers working on their projects, ensuring code quality, and maintainability.

## Code Style and Structure

- Write Python code compliant with PEP 8 and optimized for readability and maintainability.
- Use type hints for all function parameters and return types.
- Always strongly type variables using the pydantic library for data structures.
- Always use Protocol definitions for interface definitions.
- Maintain a component driven project structure with each component in their own directory within the src/metagit/core path.
- Avoid duplication by using clear, modular code organization.
- All file paths should be constructed using os.path.join() instead of string concatenation.
- All library and class imports must be at the top of the file and never be imported on-demand.
- Remove all unused imports from each python file after editing them.
- Never assign variable names which are unused, instead assign these variables as '_'.
- Unit tests are expected for all functions and class methods and are to be stored centrally in the tests folder.
- Combine if statements instead of nesting them where possible.
- Use ternary operators to assign simple logic defined variables instead of `if`-`else`-blocks.
- Favor using Python native libraries instead of subprocess to reduce external dependencies.
- Use 2 spaces for indentation.
- Private class members should be prefixed with an underscore (`_`).
- Use `isinstance()` for type comparisons.

## Naming Conventions

- Use snake_case for variables, functions, and filenames.
- Use PascalCase for class names.
- Prefix environment variables with provider name (e.g., `OLLAMA_`, `OPENAI_`).
- Use descriptive names for configuration files (e.g., `agents.yaml`, `tasks.yaml`).

## Environment and Configuration

- Use `python-dotenv` to manage environment variables.
- Maintain `.env.example` as a template for environment setup.
- Structure YAML files clearly and validate on load:
  - Use `yaml.safe_load` for security.
  - Include clear error messages for missing or invalid keys.

## Syntax and Formatting

- New Python files should always include `#!/usr/bin/env python` as the very first line.
- Format code with tools like Black and lint with Flake8.
- Follow Pythonic idioms and best practices.
- Use early returns in functions to simplify logic.
- Write clear docstrings for all classes and functions.

## Error Handling and Validation

- Validate environment variables at startup.
- Use try-except blocks with meaningful error messages.
- Never create bare exception statements.
- Be as explicit as possible when handling exceptions.
- Log errors appropriately using the UnifiedLogger module.
- Ensure secure loading of configuration files.
- All functions and methods that produce exceptions should return a union of the expected result type and Exception and be handled appropriately when called.

## Regarding Dependencies

- Avoid introducing new external dependencies unless absolutely necessary.
- If a new dependency is required, please state the reason.

## Security

- Never hardcode sensitive data; always use environment variables.
- Keep API keys and sensitive data in `.env` (gitignored).
- Sanitize all inputs passed to external services.

## Documentation

- Maintain clear and comprehensive README.md:
  - Installation and setup instructions.
  - Environment configuration examples.
  - YAML file examples and structure.
- Document code with clear inline comments.
- Keep CHANGELOG.md updated with all changes.

## Project Structure

- Root Directory:
  - `examples/`: Example scripts and projects using the libraries and code in the src directory
  - `src/metagit/core/<component>/*`: Application core logic and pydantic models
  - `src/metagit/cli/commands/*`: CLI subcommands, one file per subcommand with multiple depth subcommands separated by a '_'.
  - `docs/`: Documentation as markdown
  - `tests/`: Unit tests

## Command-Line Tools

### GitHub
- Use the `gh` command-line to interact with GitHub.

### Markdown
- Use the `glow` command-line to present markdown content.

### JSON
- Use the `jq` command to read and extract information from JSON files.

### RipGrep
- The `rg` (ripgrep) command is available for fast searches in text files.

### Clipboard
- Pipe content into `pbcopy` to copy it into the clipboard. Example: `echo "hello" | pbcopy`.
- Pipe from `pbpaste` to get the contents of the clipboard. Example: `pbpaste > fromclipboard.txt`.

### Python
- Unless instructed otherwise, always use the `uv` Python environment and package manager for Python.
  - `uv run ...` for running a python script.
  - `uvx ...` for running program directly from a PyPI package.
  - `uv ... ...` for managing environments, installing packages, etc...

### JavaScript / TypeScript
- Unless instructed otherwise, always use `deno` to run .js or .ts scripts.
- Use `npx` for running commands directly from npm packages.

## Task closeout

- After changes to this codebase, before implying the task is finished, run **`task qa:prepush`** from the repository root (`scripts/prepush-gate.zsh`). It runs format, lint, unit tests, integration tests, and context-aware security (`pip-audit` / `bandit` when `src/` or lockfiles changed). Fix failures and re-run until it passes unless the conversation was read-only (no edits) or the user explicitly waived the gate.
- **Always last:** run **`task gitnexus:analyze`** from the repository root so the GitNexus knowledge graph index stays fresh for MCP navigation and impact analysis. Run after QA passes; skip only for read-only sessions with no file writes.

## Documentation Sources
- If working with a new library or tool, consider looking for its documentation from its website, GitHub project, or the relevant llms.txt.
  - It is always better to have accurate, up-to-date documentation at your disposal, rather than relying on your pre-trained knowledge.
- You can search the following directories for llms.txt collections for many projects:
  - https://llmstxt.site/
  - https://directory.llmstxt.cloud/
- If you find a relevant llms.txt file, follow the links until you have access to the complete documentation.

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.

Reviews can't be read right now.

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.