rich

Coding and project-structure rules for Rich, a Python library used to build formatted terminal applications.

In plain words
What is it for?
Use it when writing or reviewing Python terminal applications that use Rich.
Why use it?
It provides consistent guidance for readable Python code, project layout, dependencies, and supported Python versions.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/synmux/myriad/rich
Clone the repo
git clone --depth 1 https://github.com/synmux/myriad
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 2,180 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.02180
Opus 5 $0.00000 $0.01090
Sonnet 5 $0.00000 $0.00436
Haiku 4.5 $0.00000 $0.00218

Measured 2d ago against content hash d1d60d9b1137, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

rich scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

configuration/cursor/rules/rich.mdc · 160 lines

How it starts

The opening of the file, as written. The whole thing — 160 lines — stays where its author put it; the contents beside it link to each section on GitHub.

  • General Guidelines

    • Adhere to PEP 8 coding style guidelines for Python code, emphasizing readability and consistency.
    • Limit lines to a maximum of 79 characters to enhance readability across different environments.
    • Prioritize code clarity and simplicity, making it easy to understand and maintain.
    • Use UTF-8 encoding for source files to ensure compatibility with a wide range of characters.
  • Installation and Environment

    • Use uv for installing dependencies to improve speed and reliability, if appropriate.
    • Specify Python 3.12 or later to leverage the latest language features and performance improvements. (If applicable for the specific features of rich you are using)
  • Code Organization and Structure

    • Directory Structure: Follow a logical directory structure.

      project_root/ ├── src/ │ ├── main.py # Entry point of the application │ ├── utils/ │ │ ├── init.py │ │ ├── helper_functions.py │ ├── modules/ │ │ ├── init.py │ │ ├── module_a.py # Rich-related components │ │ ├── module_b.py ├── tests/ │ ├── init.py │ ├── test_main.py │ ├── test_module_a.py ├── README.md ├── pyproject.toml # Or requirements.txt

    • File Naming: Use descriptive lowercase names with underscores (e.g., console_output.py).

    • Module Organization: Group related functionalities into separate modules (e.g., rich_display.py, data_formatting.py).

    • Component Architecture: Design modular components with clear interfaces for reusability and maintainability.

    • Code Splitting: Break down large files into smaller, more manageable pieces based on functionality. Consider lazy loading of less-frequently used modules.

  • Coding Style and Best Practices

    • Indentation: Use 4 spaces for indentation.
    • Blank Lines: Separate top-level functions and classes with two blank lines, and methods within a class with one blank line.
    • Imports:
      • Group imports in the following order:
        1. Standard library imports
        2. Third-party library imports (including Rich)
        3. Local application imports
      • Use absolute imports for clarity, unless relative imports significantly improve readability within a package.
      • Avoid wildcard imports (from module import *).
    • Naming Conventions:
      • Use lowercase with underscores for function and variable names (my_variable, my_function).
      • Use CapWords for class names (MyClass).
      • Use UPPER_CASE_WITH_UNDERSCORES for constants (MAX_VALUE).
    • String Quotes: Use double quotes consistently for strings, especially for docstrings.
  • Rich Library Specific Best Practices

    • Console Instantiation: Create a single Console instance for your application and reuse it throughout. python from rich.console import Console

      console = Console()

      def my_function(): console.print("Hello, [bold red]World![/bold red]")

    • Styling: Use Rich's markup system for styling text. Refer to the Rich documentation for available styles and their usage. python console.print("[link=https://example.com]Click here[/link] to visit example.com")

    • Tables: Utilize the Table class for structured data display. Configure columns and rows appropriately. python from rich.table import Table

      table = Table(title="My Data") table.add_column("Name", style="cyan", no_wrap=True) table.add_column("Age", style="magenta") table.add_row("Alice", "30") table.add_row("Bob", "25") console.print(table)

    • Progress Bars: Employ the Progress class for tracking long-running tasks. Configure the progress bar to accurately reflect the task's progress. python from rich.progress import Progress import time

      with Progress() as progress: task1 = progress.add_task("[red]Downloading...", total=1000) task2 = progress.add_task("[green]Processing...", total=100)

Read the full file on GitHub · 160 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 160 lines · 2,180 tokens per session scan A d1d60d9b1137

Subscribe to this mod's changes

rich is a cursor rule published in the GitHub repository synmux/myriad (2 stars, last pushed 2d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,180 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.