Skip to content

Conversation

@kzndotsh
Copy link
Contributor

@kzndotsh kzndotsh commented Dec 7, 2025

Pull Request

Description

Provide a clear summary of your changes and reference any related issues. Include the motivation behind these changes and list any new dependencies if applicable.

If your PR is related to an issue, please include the issue number below:

Related Issue: Closes #

Type of Change:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Code refactoring
  • Test improvements

Guidelines

  • My code follows the style guidelines of this project (formatted with Ruff)

  • I have performed a self-review of my own code

  • I have commented my code, particularly in hard-to-understand areas

  • I have made corresponding changes to the documentation if needed

  • My changes generate no new warnings

  • I have tested this change

  • Any dependent changes have been merged and published in downstream modules

  • I have added all appropriate labels to this PR

  • I have followed all of these guidelines.

How Has This Been Tested? (if applicable)

Please describe how you tested your code. e.g describe what commands you ran, what arguments, and any config stuff (if applicable)

Screenshots (if applicable)

Please add screenshots to help explain your changes.

Additional Information

Please add any other information that is important to this PR.

Summary by Sourcery

Integrate a Cursor-based rules and commands system into the project and document how to use and validate it as part of the standard development workflow.

New Features:

  • Add a dedicated rules CLI (uv run rules …) for validating Cursor rules and commands and expose it via the project scripts entry point.
  • Introduce a structured catalog of Cursor commands for common workflows (code quality, testing, database, Discord, docs, security, debugging, development) under .cursor/commands.
  • Add domain-specific Cursor rules for database, modules, testing, security, error handling, and meta specifications, along with reusable rule/command templates.

Enhancements:

  • Expand AGENTS.md and project structure docs to describe the Cursor rules/commands directory layout, validation command, and how it fits into the development workflow and quality checks.
  • Update the developer guides index and navigation to list new Cursor rule/command creation guides and replace the generic WIP notice with concrete content.
  • Clarify the database stack documentation to reference psycopg async for PostgreSQL.

Build:

  • Register the new rules CLI in pyproject.toml so it can be invoked via uv run rules.

CI:

  • Add a pre-commit hook to run uv run rules validate on .cursor rule and command changes to enforce consistency and standards.

Documentation:

  • Add detailed developer guides for creating Cursor rules and commands, including structure, metadata, examples, validation, and maintenance practices.
  • Create a .cursor/README.md explaining the rules and commands system, directory structure, usage patterns, and contribution guidelines.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Dec 7, 2025

Reviewer's Guide

Introduces a Cursor-focused rules and commands system into the Tux repo, including a rules CLI for validating rule/command files, documentation and navigation updates, new .cursor README/templates, multiple project-specific Cursor commands/rules, and a pre-commit hook to enforce validation.

Sequence diagram for rules validation via pre-commit and CLI

sequenceDiagram
    actor Developer
    participant Git as GitPreCommit
    participant PreCommit as PreCommitHook
    participant Uv as UvRunner
    participant RulesEntrypoint as ScriptsRulesMain
    participant RulesCLI as RulesCLI
    participant FS as FileSystem

    Developer->>Git: git commit
    Git->>PreCommit: run hooks
    PreCommit->>PreCommit: validate-rules hook
    PreCommit->>Uv: uv run rules validate --rules-dir .cursor/rules --commands-dir .cursor/commands
    Uv->>RulesEntrypoint: scripts.rules:main()
    RulesEntrypoint->>RulesCLI: RulesCLI()
    RulesEntrypoint->>RulesCLI: cli.run()

    RulesCLI->>FS: list .cursor/rules/*.mdc
    loop For each rule file
        RulesCLI->>FS: read rule file
        RulesCLI->>RulesCLI: _validate_rule(file_path)
    end

    RulesCLI->>FS: list .cursor/commands/**/*.md
    loop For each command file
        RulesCLI->>FS: read command file
        RulesCLI->>RulesCLI: _validate_command(file_path)
    end

    RulesCLI->>RulesCLI: _print_validation_summary(...)
    alt validation errors
        RulesCLI-->>Uv: exit code 1
        Uv-->>PreCommit: non-zero exit
        PreCommit-->>Git: hook failed
        Git-->>Developer: commit blocked, show errors
    else all valid
        RulesCLI-->>Uv: exit code 0
        Uv-->>PreCommit: success
        PreCommit-->>Git: hook passed
        Git-->>Developer: commit proceeds
    end
Loading

Class diagram for the new RulesCLI validation system

classDiagram
    class BaseCLI {
        +str name
        +str description
        +console
        +app
        +_command_registry
        +__init__(name, description)
        +add_command(func, name, help_text)
        +run()
    }

    class Command {
        +str name
        +callable func
        +str help_text
        +__init__(name, func, help_text)
    }

    class RulesCLI {
        +__init__()
        -_setup_command_registry() void
        -_setup_commands() void
        -_check_rule_frontmatter(file_path, content) tuple~list~str~~, str or None~
        -_check_rule_description(file_path, frontmatter, is_spec, is_reference) list~str~
        -_check_rule_content(file_path, content, frontmatter_end, is_spec, is_reference, is_docs_rule) list~str~
        -_validate_rule(file_path) list~str~
        -_validate_command(file_path) list~str~
        +validate(rules_dir, commands_dir) void
        -_print_validation_summary(rule_files, cmd_files, all_errors) void
    }

    class TyperApp {
        +callback()
        +command()
        +__call__()
    }

    BaseCLI <|-- RulesCLI
    RulesCLI o--> Command : registers
    RulesCLI o--> TyperApp : uses app

    class RulesModule {
        +app
        +main() void
    }

    RulesModule ..> RulesCLI : instantiates
    RulesModule ..> TyperApp : exposes as app
Loading

File-Level Changes

Change Details Files
Add a dedicated rules Typer CLI for validating Cursor rules and commands and wire it into the existing scripts/CLI ecosystem.
  • Implement RulesCLI in scripts/rules.py using Typer and the existing BaseCLI/Command registry pattern.
  • Provide validate command that walks .cursor/rules and .cursor/commands, applying structural/content rules to each file type.
  • Add internal helpers to check rule frontmatter, description, content, file size, and command sections, and to print a rich validation summary table.
  • Expose the new CLI via rules = "scripts.rules:main" in pyproject.toml and export RulesCLI from scripts/init.py.
scripts/rules.py
pyproject.toml
scripts/__init__.py
Integrate rules/commands validation into developer workflow, pre-commit, and AGENTS documentation.
  • Document uv run rules validate in AGENTS.md (setup, workflow, troubleshooting, and checklist sections).
  • Add .cursor/ directory description to the project structure tree in AGENTS.md.
  • Update development workflow steps to include rules validation before commit and extend the final review checklist to require rules/commands validation.
  • Add a troubleshooting entry for rules validation under AGENTS.md quality/test commands section.
  • Add a local pre-commit hook that runs uv run rules validate against .cursor/rules and .cursor/commands changes.
AGENTS.md
.pre-commit-config.yaml
Extend developer documentation to cover Cursor rules/commands and reflect them in site navigation and .cursor README.
  • Replace the placeholder warning in developer guides index with an "Available Guides" list including new Cursor-related guides.
  • Add new guides describing how to create Cursor rules and Cursor commands, including structure, metadata, patterns, templates, and validation flow.
  • Wire new guides into the docs navigation in zensical.toml under Developer Guides.
  • Add .cursor/README.md explaining the rules/commands directory structure, domains/categories, usage patterns, and contribution references.
docs/content/developer/guides/index.md
docs/content/developer/guides/creating-cursor-rules.md
docs/content/developer/guides/creating-cursor-commands.md
zensical.toml
.cursor/README.md
Seed a library of Cursor commands for common Tux workflows across development, testing, database, docs, security, and Discord operations.
  • Add command markdown files under .cursor/commands/ for development (setup-project, docker-up/down), code-quality (lint, refactor, review-existing-diffs), testing (write-unit-tests, run-all-tests-and-fix, test-coverage, integration-tests), database (migration, reset, health), Discord (create-module, test-command), docs (generate-docs, update-docs, docs-serve), security (security-review), debugging (debug).
  • Ensure each command follows the common template: H1 title, Overview, ordered Steps, optional Error Handling, Checklist, and See Also cross-references to commands/rules.
.cursor/commands/development/setup-project.md
.cursor/commands/development/docker-up.md
.cursor/commands/development/docker-down.md
.cursor/commands/code-quality/lint.md
.cursor/commands/code-quality/refactor.md
.cursor/commands/code-quality/review-existing-diffs.md
.cursor/commands/testing/write-unit-tests.md
.cursor/commands/testing/run-all-tests-and-fix.md
.cursor/commands/testing/test-coverage.md
.cursor/commands/testing/integration-tests.md
.cursor/commands/database/migration.md
.cursor/commands/database/reset.md
.cursor/commands/database/health.md
.cursor/commands/discord/create-module.md
.cursor/commands/discord/test-command.md
.cursor/commands/documentation/generate-docs.md
.cursor/commands/documentation/update-docs.md
.cursor/commands/documentation/docs-serve.md
.cursor/commands/security/security-review.md
.cursor/commands/debugging/debug.md
.cursor/templates/command-template.md
Expand and reorganize Cursor rules to cover more Tux domains and update existing rule files to match the new validation constraints.
  • Introduce new .cursor/rules files for database (migrations, queries, services), modules (cogs, commands, events, interactions, permissions), testing (pytest, fixtures, markers, async, coverage), security (patterns, dependencies, secrets, validation), error handling (patterns, logging, sentry, user-feedback), and meta specifications (cursor-rules, cursor-commands).
  • Adjust existing core/docs/database/ui rule files (e.g., core/tech-stack.mdc, database/controllers.mdc, models.mdc, docs/docs.mdc, ui/cv2.mdc, rules.mdc) to satisfy the validator’s expectations around frontmatter, descriptions, patterns, examples, and file size where applicable.
  • Add a reusable rule template .cursor/templates/rule-template.mdc and remove obsolete or superseded database rule stubs (overview.mdc, service.mdc).
.cursor/rules/core/tech-stack.mdc
.cursor/rules/database/controllers.mdc
.cursor/rules/database/models.mdc
.cursor/rules/docs/docs.mdc
.cursor/rules/ui/cv2.mdc
.cursor/rules/rules.mdc
.cursor/rules/database/migrations.mdc
.cursor/rules/database/queries.mdc
.cursor/rules/database/services.mdc
.cursor/rules/error-handling/logging.mdc
.cursor/rules/error-handling/patterns.mdc
.cursor/rules/error-handling/sentry.mdc
.cursor/rules/error-handling/user-feedback.mdc
.cursor/rules/meta/cursor-commands.mdc
.cursor/rules/meta/cursor-rules.mdc
.cursor/rules/modules/cogs.mdc
.cursor/rules/modules/commands.mdc
.cursor/rules/modules/events.mdc
.cursor/rules/modules/interactions.mdc
.cursor/rules/modules/permissions.mdc
.cursor/rules/security/dependencies.mdc
.cursor/rules/security/patterns.mdc
.cursor/rules/security/secrets.mdc
.cursor/rules/security/validation.mdc
.cursor/rules/testing/async.mdc
.cursor/rules/testing/coverage.mdc
.cursor/rules/testing/fixtures.mdc
.cursor/rules/testing/markers.mdc
.cursor/rules/testing/pytest.mdc
.cursor/templates/rule-template.mdc
.cursor/rules/database/overview.mdc
.cursor/rules/database/service.mdc
Align AGENTS and database stack description with current PostgreSQL driver choice and add dev helper commands.
  • Update AGENTS.md database stack description from PostgreSQL (asyncpg) to PostgreSQL (psycopg async).
  • Document uv run dev all and uv run dev pre-commit under Quality checks in AGENTS.md.
AGENTS.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions
Copy link
Contributor

github-actions bot commented Dec 7, 2025

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes - here's some feedback:

  • In scripts/rules.py, validate() currently exits with an error if either the rules or commands directory is missing; consider treating a missing directory as an empty set (or making each optional) so validation can still run in repos/branches that only use one of the two.
  • The extension checks in _validate_rule and _validate_command are redundant because you already filter files with rglob('*.mdc') and rglob('*.md'); you can remove those checks to simplify the validators.
  • You construct RulesCLI twice (once for the module-level app and again in main()); reusing a single instance or delegating main() to the existing app would reduce duplicate setup logic.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `scripts/rules.py`, `validate()` currently exits with an error if either the rules or commands directory is missing; consider treating a missing directory as an empty set (or making each optional) so validation can still run in repos/branches that only use one of the two.
- The extension checks in `_validate_rule` and `_validate_command` are redundant because you already filter files with `rglob('*.mdc')` and `rglob('*.md')`; you can remove those checks to simplify the validators.
- You construct `RulesCLI` twice (once for the module-level `app` and again in `main()`); reusing a single instance or delegating `main()` to the existing `app` would reduce duplicate setup logic.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 7, 2025

📚 Documentation Preview

Type URL Version Message
Production https://tux.atl.dev - -
Preview https://ff49a5c2-tux-docs.allthingslinux.workers.dev ff49a5c2-6868-4e6a-8990-039c9a005d6c Preview: tux@c9226af3fc6923d215c0fb76b5d42d35a05c31de on 1101/merge by kzndotsh (run 243)

@sentry
Copy link

sentry bot commented Dec 7, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 40.24%. Comparing base (8a7f168) to head (27ae21a).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1101   +/-   ##
=======================================
  Coverage   40.24%   40.24%           
=======================================
  Files         204      204           
  Lines       14373    14373           
  Branches     1686     1686           
=======================================
  Hits         5784     5784           
  Misses       8589     8589           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

- Introduced `CursorCLI` for validating rules and commands against Tux project standards.
- Added validation logic for rule frontmatter, description, content, and command structure.
- Integrated a new pre-commit hook to validate cursor rules and commands during commits.
- Introduced new markdown files for linting, refactoring, reviewing diffs, and database operations.
- Each file outlines steps, checklists, and error handling for maintaining code quality in the Tux project.
- Enhanced documentation for Docker commands and testing procedures to streamline development processes.
- Changed the entry command for the cursor validation hook to include 'validate' for improved clarity and functionality.
- Removed unnecessary arguments from the hook configuration to streamline the validation process.
- Added a new `RulesCLI` for validating rules and commands against Tux project standards.
- Updated pre-commit configuration to use the new validation command.
- Enhanced the `pyproject.toml` to include the rules CLI entry point.
- Refactored existing code to integrate the new validation logic and ensure proper command structure.
- Added a comprehensive catalog of all Cursor rules and commands for the Tux project, enhancing clarity and accessibility.
- Updated individual rule files with detailed descriptions, best practices, and anti-patterns for various components, including database, modules, and security.
- Introduced new files for database migrations, queries, and service patterns, ensuring a structured approach to database operations.
- Enhanced documentation for error handling, logging, and testing patterns to improve overall code quality and maintainability.
- Removed outdated overview files and streamlined the organization of rules for better navigation and usability.
- Introduced new markdown templates for commands and rules to standardize documentation practices.
- The command template includes sections for overview, steps, error handling, and checklists.
- The rule template features patterns, best practices, anti-patterns, and examples to guide users in implementation.
- These templates aim to enhance clarity and consistency in documenting commands and rules within the Tux project.
…nd rules

- Introduced two new guides: "Creating Cursor Commands" and "Creating Cursor Rules" to provide step-by-step instructions for developers.
- Each guide includes quick start sections, detailed steps, best practices, and templates to standardize the creation of commands and rules within the Tux project.
- Updated the main developer guides index to include links to the new guides, enhancing accessibility and organization of documentation resources.
- Introduced a new README file detailing the structure and usage of Cursor's rules and commands system.
- Provided an overview of rules and commands, their organization by domain and category, and instructions for usage.
- Included links to comprehensive guides and resources for contributing to Cursor rules and commands, enhancing developer onboarding and documentation accessibility.
- Added a new section detailing Cursor's rules and commands system, including their organization and usage.
- Included validation commands and links to comprehensive guides for creating rules and commands.
- Updated development workflow to incorporate rules validation as a step before committing changes.
- Improved documentation structure for better clarity and accessibility of Cursor-related resources.
- Included links to "Creating Cursor Rules" and "Creating Cursor Commands" in the developer guides index.
- These additions enhance the documentation structure and provide developers with essential resources for implementing Cursor functionalities.
…dling

- Added autofix and autoupdate commit message formats for pre-commit hooks.
- Excluded validation rules from the pre-commit checks to streamline the process.
- Updated Python version specification to 3.13 for consistency.
@coderabbitai
Copy link

coderabbitai bot commented Dec 30, 2025

Walkthrough

Adds a Cursor “rules & commands” documentation suite (many .cursor/rules/ and .cursor/commands/ files), templates, docs/site updates, a Typer-based AI CLI group with a validate-rules tool (scripts/ai/validate_rules.py), pyproject script registration, and a pre-commit hook to run the validator. No runtime library logic changes.

Changes

Cohort / File(s) Summary
Cursor index & overview
.cursor/README.md, .cursor/rules/rules.mdc
New Cursor README and updated rules index wording and description.
Rule & spec definitions
.cursor/rules/meta
\.cursor/rules/meta/cursor-rules.mdc`, `.cursor/rules/meta/cursor-commands.mdc`, `.cursor/templates/rule-template.mdc`, `.cursor/templates/command-template.md``
New specifications and templates defining metadata, file formats, canonical structure, and validation guidance.
Database rules (added/reworked)
.cursor/rules/database
\.cursor/rules/database/migrations.mdc`, `.cursor/rules/database/models.mdc`, `.cursor/rules/database/queries.mdc`, `.cursor/rules/database/services.mdc`, (deleted: `.cursor/rules/database/overview.mdc`, `.cursor/rules/database/service.mdc``)
Reorganized DB guidance: migrations, models (BaseModel conventions), queries, and service patterns; removed older overview/service docs.
Modules / bot patterns
.cursor/rules/modules
\.cursor/rules/modules/*.mdc``
New Discord bot architecture rules: cogs, commands, events, interactions, permissions.
Error handling & observability
.cursor/rules/error-handling
\.cursor/rules/error-handling/*.mdc`, `.cursor/rules/error-handling/sentry.mdc``
New logging, error-handling, Sentry, and user-feedback guidelines.
Security rules
.cursor/rules/security
\.cursor/rules/security/*.mdc``
New security patterns: dependency management, secrets, validation, secure-coding guidance.
Testing rules
.cursor/rules/testing
\.cursor/rules/testing/*.mdc``
New testing guidance: pytest config, async testing, fixtures, markers, coverage.
Commands (workflows & templates)
.cursor/commands/**
\.cursor/commands/**/*.md``
Many new user-facing command guides and checklists (lint, refactor, migrations, db health/reset/migration, docker up/down, setup, debugging, docs, testing, security review, etc.).
Templates & docs site
docs/content/developer/guides/creating-cursor-rules.md, docs/content/developer/guides/creating-cursor-commands.md, docs/content/developer/guides/index.md, AGENTS.md, zensical.toml
Developer guides for creating Cursor rules/commands, docs index updates, AGENTS.md integration, and nav additions.
Validation CLI & CLI registration
scripts/ai/validate_rules.py, scripts/ai/__init__.py, scripts/__init__.py, pyproject.toml
New Typer-based AI CLI group and validate-rules command, CLI registration, and ai script entry added.
Pre-commit & CI
.pre-commit-config.yaml
Adds local validate-rules pre-commit hook, consolidates CI section, and adjusts some hook versions.
Added / removed docs
.cursor/commands/deslop.md (deleted) plus many new .md/.mdc files
Removed legacy Deslop doc and replaced it with targeted command docs and rules.
Misc edits
.cursor/rules/core/tech-stack.mdc, .cursor/rules/docs/docs.mdc, .cursor/rules/ui/cv2.mdc
Small content tweaks, added See Also references and workflow examples.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor Developer
    participant CLI as scripts.ai (Typer)
    participant Validator as validate_rules
    participant FS as Filesystem (.cursor/.cursor/commands)
    participant Console as Console

    Developer->>CLI: run `ai validate-rules`
    CLI->>Validator: dispatch validate_rules command
    Validator->>FS: enumerate & read rule (`*.mdc`) and command (`*.md`) files
    FS-->>Validator: return file contents
    Validator->>Validator: parse frontmatter & content checks
    Validator->>Console: print per-file errors/warnings
    Validator->>Console: print summary (counts & status)
    Console-->>Developer: validation result (pass/fail)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • refactor: scripts #1108: Overlaps in CLI surface — both modify the scripts package and CLI registration related to adding new command groups.
  • cleanup: tests and slop #1124: Touches the same Deslop documentation content (add/remove/modify), indicating overlapping documentation changes.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'docs: agentic rules and commands' clearly summarizes the main change of adding Cursor-based rules and commands documentation and tooling to the project.
Description check ✅ Passed The description is related to the changeset, providing a detailed summary of the new Cursor rules/commands system, validation CLI, documentation, templates, and CI integration changes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/agents

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 419f2a2 and 27ae21a.

📒 Files selected for processing (1)
  • scripts/ai/validate_rules.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • scripts/ai/validate_rules.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Run All Tests (3.13.8)
  • GitHub Check: Sourcery review

Comment @coderabbitai help to get the list of available commands and usage tips.

scripts/rules.py Outdated
Comment on lines 18 to 19
from scripts.base import BaseCLI
from scripts.registry import Command

This comment was marked as outdated.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 13

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.cursor/rules/ui/cv2.mdc (1)

52-77: Duplicate "Best Practices" section creates confusion about scope and structure.

The file now has two "Best Practices" sections:

  • Lines 52–60: LayoutView-specific best practices (newly added)
  • Lines 610–622: Broader UI pattern best practices (existing)

These serve different purposes but share the same heading, making it unclear which guidance applies and creating maintenance burden. Additionally, the placement of the new section immediately after "LayoutView Methods" (without explicit sub-heading) suggests it belongs to that section, but the content is broader guidance.

Recommendation: Either (a) rename the new section to "LayoutView Best Practices" to clarify scope, (b) move it to the end of the LayoutView section as a subsection, or (c) merge both "Best Practices" sections into a unified guide with LayoutView-specific callouts.

🧹 Nitpick comments (11)
.cursor/commands/development/docker-down.md (1)

21-25: Consider making the data loss warning more prominent.

The warning about potential data loss is important but might be overlooked in a plain "Notes" section. If the documentation format supports it, consider using:

  • A warning/danger admonition block
  • Bold or emphasized text for the data loss line
  • Moving it higher in the document (before Steps)

This is particularly important since data loss can significantly impact developers.

.cursor/rules/security/secrets.mdc (1)

1-5: Verify glob pattern scope for configuration files.

The glob pattern config/*.toml, config/*.yaml, config/*.json only matches files at the root level of the config/ directory. If nested configuration files are expected (e.g., config/db/*.toml), the pattern should use config/**/*.{toml,yaml,json} to capture subdirectories.

Verify whether configuration files are stored in nested subdirectories under config/ and adjust the glob pattern accordingly if needed.

.cursor/commands/debugging/debug.md (1)

30-41: Add "See Also" section for consistency with other command guides.

All other command guides (generate-docs, refactor, write-unit-tests) include a "See Also" section with cross-references. This guide should include one as well, linking to related debugging rules and other debugging-related commands.

🔎 Suggested structure
## See Also

- Related rule: @error-handling/patterns.mdc
- Related rule: @debugging/logging.mdc (if available)
- Related command: `/logs` (if available)
.cursor/rules/database/services.mdc (1)

118-129: Transaction guidance could be more prominent.

Transactions are covered under "Async Operations" section, but given their importance for multi-step database operations, consider elevating this pattern to a dedicated section or emphasizing it earlier in the document. Based on learnings, transactions are a critical pattern for data consistency in multi-step operations.

.cursor/rules/database/migrations.mdc (1)

39-67: Unused sqlmodel import in migration example.

Line 45 imports sqlmodel but it's not used in the example migration. While this may reflect autogenerated migrations, consider removing it or adding a comment explaining when it would be used.

🔎 Optional cleanup
 from __future__ import annotations
 
 from typing import Sequence, Union
 
 from alembic import op
 import sqlalchemy as sa
-import sqlmodel
+# import sqlmodel  # Only needed when migrating SQLModel-specific types
.cursor/rules/modules/events.mdc (1)

101-108: Prefer guard clauses over assert for type narrowing.

Line 105 uses assert member.guild for type narrowing, but this will crash at runtime if the assertion fails. The actual codebase uses guard clauses (e.g., if not channel.guild: return in event.py), which is safer.

🔎 Proposed fix
 @commands.Cog.listener()
 async def on_member_join(self, member: discord.Member) -> None:
     """Handle member joins."""
-    assert member.guild
+    if not member.guild:
+        return
     # Welcome member, assign roles, etc.
     pass
.cursor/rules/database/models.mdc (1)

126-131: Clarify that this DateTime example is for custom date fields, not timestamps.

This example could be confused with the earlier guidance that timestamps are automatic. Consider adding a comment clarifying this is for custom DateTime fields (e.g., scheduled_at, expires_at), not created_at/updated_at.

🔎 Proposed fix
-# DateTime with timezone
+# DateTime with timezone (for custom date fields, NOT timestamps)
 created_at: datetime | None = Field(
+    # Note: Use a different name like scheduled_at, expires_at, etc.
+    # created_at/updated_at are automatic from BaseModel
     sa_type=DateTime(timezone=True),
-    description="Creation timestamp"
+    description="Custom datetime field"
 )
scripts/rules.py (3)

464-471: Double instantiation of RulesCLI.

Line 465 creates a RulesCLI instance for the module-level app, and main() creates another instance. This is inefficient and could cause issues if the CLI has stateful initialization.

Consider reusing the same instance:

🔎 Proposed fix
 # Create the CLI app instance
-app = RulesCLI().app
+_cli = RulesCLI()
+app = _cli.app
 
 
 def main() -> None:
     """Entry point for the cursor CLI script."""
-    cli = RulesCLI()
-    cli.run()
+    _cli.run()

85-94: Frontmatter detection could be fragile with edge cases.

Line 88 checks for "---\n" starting at position 4, which assumes the file starts with exactly ---\n. This could miss edge cases like BOM characters or CRLF line endings.

Consider using a more robust regex match:

🔎 Proposed fix
     def _check_rule_frontmatter(
         self,
         file_path: Path,
         content: str,
     ) -> tuple[list[str], str | None]:
         ...
         errors: list[str] = []
+        
+        # Normalize line endings for consistent parsing
+        content = content.replace('\r\n', '\n')
 
         if not content.startswith("---"):
             errors.append(f"{file_path}: Rule must start with frontmatter (---)")
+            return errors, None
 
-        if "---\n" not in content[4:]:
+        # Find closing frontmatter delimiter
+        second_delim = content.find("---\n", 4)
+        if second_delim == -1:
             errors.append(f"{file_path}: Rule must have closing frontmatter (---)")

231-234: Consider handling file read errors gracefully.

read_text() can raise exceptions for encoding issues or permission errors. Consider wrapping in try-except to provide a clearer error message.

🔎 Proposed fix
     def _validate_rule(self, file_path: Path) -> list[str]:
         ...
         errors: list[str] = []
-        content = file_path.read_text(encoding="utf-8")
+        try:
+            content = file_path.read_text(encoding="utf-8")
+        except (OSError, UnicodeDecodeError) as e:
+            return [f"{file_path}: Failed to read file: {e}"]
.cursor/rules/testing/pytest.mdc (1)

111-132: Clarify the relationship between the async marker and @pytest.mark.asyncio decorator.

The markers list (line 116) defines an async marker, but the async test example (line 128) uses @pytest.mark.asyncio from pytest-asyncio. These are different conventions. The documentation should clarify: Are both needed? Should developers use asyncio (required for pytest-asyncio to recognize async tests) or the custom async marker (for filtering)? Consider using both if they serve different purposes (asyncio for pytest-asyncio support, async for test categorization), but make this explicit.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8a7f168 and 94abd23.

📒 Files selected for processing (62)
  • .cursor/README.md
  • .cursor/commands/code-quality/lint.md
  • .cursor/commands/code-quality/refactor.md
  • .cursor/commands/code-quality/review-existing-diffs.md
  • .cursor/commands/database/health.md
  • .cursor/commands/database/migration.md
  • .cursor/commands/database/reset.md
  • .cursor/commands/debugging/debug.md
  • .cursor/commands/development/docker-down.md
  • .cursor/commands/development/docker-up.md
  • .cursor/commands/development/setup-project.md
  • .cursor/commands/discord/create-module.md
  • .cursor/commands/discord/test-command.md
  • .cursor/commands/documentation/docs-serve.md
  • .cursor/commands/documentation/generate-docs.md
  • .cursor/commands/documentation/update-docs.md
  • .cursor/commands/error-handling/add-error-handling.md
  • .cursor/commands/security/security-review.md
  • .cursor/commands/testing/integration-tests.md
  • .cursor/commands/testing/run-all-tests-and-fix.md
  • .cursor/commands/testing/test-coverage.md
  • .cursor/commands/testing/write-unit-tests.md
  • .cursor/rules/core/tech-stack.mdc
  • .cursor/rules/database/migrations.mdc
  • .cursor/rules/database/models.mdc
  • .cursor/rules/database/overview.mdc
  • .cursor/rules/database/queries.mdc
  • .cursor/rules/database/service.mdc
  • .cursor/rules/database/services.mdc
  • .cursor/rules/docs/docs.mdc
  • .cursor/rules/error-handling/logging.mdc
  • .cursor/rules/error-handling/patterns.mdc
  • .cursor/rules/error-handling/sentry.mdc
  • .cursor/rules/error-handling/user-feedback.mdc
  • .cursor/rules/meta/cursor-commands.mdc
  • .cursor/rules/meta/cursor-rules.mdc
  • .cursor/rules/modules/cogs.mdc
  • .cursor/rules/modules/commands.mdc
  • .cursor/rules/modules/events.mdc
  • .cursor/rules/modules/interactions.mdc
  • .cursor/rules/modules/permissions.mdc
  • .cursor/rules/rules.mdc
  • .cursor/rules/security/dependencies.mdc
  • .cursor/rules/security/patterns.mdc
  • .cursor/rules/security/secrets.mdc
  • .cursor/rules/security/validation.mdc
  • .cursor/rules/testing/async.mdc
  • .cursor/rules/testing/coverage.mdc
  • .cursor/rules/testing/fixtures.mdc
  • .cursor/rules/testing/markers.mdc
  • .cursor/rules/testing/pytest.mdc
  • .cursor/rules/ui/cv2.mdc
  • .cursor/templates/command-template.md
  • .cursor/templates/rule-template.mdc
  • .pre-commit-config.yaml
  • AGENTS.md
  • docs/content/developer/guides/creating-cursor-commands.md
  • docs/content/developer/guides/creating-cursor-rules.md
  • docs/content/developer/guides/index.md
  • pyproject.toml
  • scripts/rules.py
  • zensical.toml
💤 Files with no reviewable changes (2)
  • .cursor/rules/database/service.mdc
  • .cursor/rules/database/overview.mdc
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Use strict type hints with Type | None instead of Optional[Type]
Use NumPy docstrings for documenting functions and classes
Prefer absolute imports; relative imports allowed only within the same module
Organize imports in order: stdlib → third-party → local
Use 88 character line length
Use snake_case for functions and variables, PascalCase for classes, UPPER_CASE for constants
Always add imports to the top of the file unless absolutely necessary
Use async/await for I/O operations
Use custom exceptions for business logic with context logging and meaningful user messages
Use Pydantic for data validation
Keep files to a maximum of 1600 lines
Use one class or function per file when possible
Use descriptive filenames
Add appropriate logging to services and error handlers

Files:

  • scripts/rules.py
🧠 Learnings (11)
📚 Learning: 2025-12-28T16:20:43.646Z
Learnt from: CR
Repo: allthingslinux/tux PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T16:20:43.646Z
Learning: Applies to **/alembic/**/*.py : Use Alembic for database migrations

Applied to files:

  • .cursor/commands/database/migration.md
  • .cursor/rules/database/migrations.mdc
  • AGENTS.md
📚 Learning: 2025-12-28T16:20:43.646Z
Learnt from: CR
Repo: allthingslinux/tux PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T16:20:43.646Z
Learning: No secrets in code; use environment variables for configuration

Applied to files:

  • .cursor/rules/security/secrets.mdc
📚 Learning: 2025-12-28T16:20:43.646Z
Learnt from: CR
Repo: allthingslinux/tux PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T16:20:43.646Z
Learning: Applies to **/database/**/*.py : Use transactions for multi-step database operations

Applied to files:

  • .cursor/rules/database/services.mdc
  • .cursor/rules/database/migrations.mdc
  • AGENTS.md
📚 Learning: 2025-12-28T16:20:43.646Z
Learnt from: CR
Repo: allthingslinux/tux PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T16:20:43.646Z
Learning: Applies to **/database/**/*.py : Optimize database queries

Applied to files:

  • .cursor/rules/database/queries.mdc
  • AGENTS.md
📚 Learning: 2025-12-28T16:20:43.646Z
Learnt from: CR
Repo: allthingslinux/tux PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T16:20:43.646Z
Learning: Applies to **/database/**/*.py : Use SQLModel for type-safe database operations

Applied to files:

  • .cursor/rules/database/queries.mdc
  • .cursor/rules/database/migrations.mdc
  • .cursor/rules/database/models.mdc
  • AGENTS.md
📚 Learning: 2025-12-21T20:54:29.808Z
Learnt from: CR
Repo: allthingslinux/tux PR: 0
File: .cursor/rules/rules.mdc:0-0
Timestamp: 2025-12-21T20:54:29.808Z
Learning: Follow the coding agent rules defined in AGENTS.md

Applied to files:

  • .cursor/rules/meta/cursor-rules.mdc
  • AGENTS.md
📚 Learning: 2025-12-28T16:20:43.646Z
Learnt from: CR
Repo: allthingslinux/tux PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T16:20:43.646Z
Learning: Applies to **/modules/**/*.py : Implement role-based permissions for Discord commands

Applied to files:

  • .cursor/commands/discord/create-module.md
  • .cursor/rules/modules/permissions.mdc
  • .cursor/rules/modules/commands.mdc
  • .cursor/commands/discord/test-command.md
📚 Learning: 2025-12-28T16:20:43.646Z
Learnt from: CR
Repo: allthingslinux/tux PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T16:20:43.646Z
Learning: Applies to **/modules/**/*.py : Use hybrid commands (slash + traditional) for Discord commands

Applied to files:

  • .cursor/commands/discord/create-module.md
  • .cursor/rules/modules/commands.mdc
📚 Learning: 2025-12-28T16:20:43.646Z
Learnt from: CR
Repo: allthingslinux/tux PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T16:20:43.646Z
Learning: Applies to **/modules/**/*.py : Use rich embeds and implement cooldowns/rate limiting for Discord interactions

Applied to files:

  • .cursor/rules/modules/interactions.mdc
  • .cursor/rules/modules/commands.mdc
📚 Learning: 2025-12-28T16:20:43.646Z
Learnt from: CR
Repo: allthingslinux/tux PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T16:20:43.646Z
Learning: Applies to **/*.py : Use custom exceptions for business logic with context logging and meaningful user messages

Applied to files:

  • .cursor/rules/error-handling/patterns.mdc
📚 Learning: 2025-12-28T16:20:43.646Z
Learnt from: CR
Repo: allthingslinux/tux PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T16:20:43.646Z
Learning: Applies to **/database/**/*.py : Use model-level validation in SQLModel models

Applied to files:

  • .cursor/rules/database/models.mdc
🧬 Code graph analysis (5)
.cursor/rules/modules/interactions.mdc (7)
src/tux/core/bot.py (1)
  • Tux (45-403)
src/tux/modules/tools/tldr.py (1)
  • slash_tldr (244-263)
src/tux/modules/info/info.py (1)
  • Info (25-851)
src/tux/modules/utility/wiki.py (1)
  • Wiki (19-180)
src/tux/modules/moderation/report.py (2)
  • report (31-42)
  • Report (16-42)
src/tux/core/context.py (1)
  • _get_interaction_details (25-47)
src/tux/ui/modals/report.py (1)
  • on_submit (65-134)
.cursor/rules/error-handling/patterns.mdc (2)
src/tux/core/app.py (1)
  • TuxApp (57-224)
src/tux/core/bot.py (1)
  • Tux (45-403)
.cursor/rules/modules/events.mdc (1)
src/tux/services/handlers/event.py (1)
  • EventHandler (12-138)
.cursor/rules/modules/permissions.mdc (1)
src/tux/modules/moderation/purge.py (1)
  • Purge (20-234)
.cursor/rules/modules/commands.mdc (1)
src/tux/modules/moderation/purge.py (1)
  • Purge (20-234)
🪛 LanguageTool
.cursor/commands/code-quality/lint.md

[style] ~5-~5: Consider using a different verb for a more formal wording.
Context: ... (ruff, basedpyright) and automatically fix issues according to project coding stan...

(FIX_RESOLVE)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Run All Tests (3.13.8)
  • GitHub Check: Sourcery review
  • GitHub Check: Seer Code Review
🔇 Additional comments (75)
.cursor/rules/ui/cv2.mdc (1)

71-73: Verify cross-reference format for internal documentation links.

The "See Also" section references other documentation using @ notation (e.g., @modules/interactions.mdc, @AGENTS.md). Confirm that this reference format is:

  • Properly recognized by the Cursor rules validation system
  • Correctly resolving to actual files/rules in the repository
  • Consistent with other cross-references in the .cursor catalog

If these files don't exist or the format is incorrect, the references may break during validation or become orphaned links.

docs/content/developer/guides/index.md (1)

12-18: LGTM!

The "Available Guides" section provides clear navigation to the developer guides, including the new Cursor-related documentation. The structure is clean and follows standard Markdown conventions.

zensical.toml (1)

91-92: LGTM!

The navigation entries for the new Cursor guides are correctly structured and follow the existing pattern in the configuration file.

.cursor/commands/testing/integration-tests.md (2)

43-48: Verify mixed reference syntax is supported.

The "See Also" section uses both @ prefix (for rules) and / prefix (for commands). While this distinction makes semantic sense, ensure both syntaxes are:

  1. Documented in the meta specification files
  2. Consistently applied across all command files
  3. Will be correctly resolved/rendered for users

10-10: The integration pytest marker is properly registered in pyproject.toml (line 433), actively used throughout the test suite (10+ occurrences in test_database_controllers.py and test_database_migrations.py), and documented in .cursor/rules/testing/markers.mdc at line 20. The command is correct and no action is required.

Likely an incorrect or invalid review comment.

.cursor/commands/development/docker-down.md (1)

10-10: Verify the uv run docker down command exists.

Similar to the docker up command, please confirm that uv run docker down is a valid registered command in the project's CLI configuration.

Refer to the verification script in the docker-up.md review comment.

.cursor/rules/rules.mdc (2)

1-8: LGTM!

The updated header and description clearly communicate the purpose of this index file. The frontmatter alwaysApply: true setting ensures this catalog is readily available to users.


123-128: The relative file path references in the "See Also" section are correct. All links resolve properly from the .cursor/rules/ directory:

  • ../../AGENTS.md → repository root
  • ../README.md.cursor/README.md
  • Developer guides under ../../docs/content/developer/guides/ all exist

No changes needed.

.cursor/commands/testing/run-all-tests-and-fix.md (2)

43-47: Reference syntax verification needed.

As with other command files, verify that the @ (rules) and / (commands) reference syntax is properly documented and supported in the Cursor system.


10-10: The uv run test all command is a valid, registered project script. It is defined in pyproject.toml as test = "scripts.test:main" with the "all" subcommand implemented in scripts/test/all.py. This command is consistently documented and used throughout the project (AGENTS.md, git.md, code-review.md, ci-cd.md), confirming it is an intentional project convention. No changes needed.

Likely an incorrect or invalid review comment.

.cursor/rules/docs/docs.mdc (1)

204-214: The @ reference syntax is correct and properly supported.

This syntax is documented in .cursor/rules/meta/cursor-rules.mdc (lines 31 and 67) as the recommended approach for file references within Cursor rules. All referenced files exist and are accessible:

  • @docs/principals.mdc
  • @docs/style.mdc
  • @docs/syntax.mdc
  • @docs/structure.mdc
  • @docs/patterns.mdc
  • @docs/zensical.mdc
  • @AGENTS.md
  • @rules.mdc

No changes needed.

.cursor/templates/rule-template.mdc (1)

1-64: Template structure aligns with established pattern.

The rule template provides a clear, well-organized scaffold that matches the structure used in other rule files (secrets.mdc, coverage.mdc, etc.). The frontmatter, pattern sections, and See Also references are all appropriate.

.cursor/templates/command-template.md (1)

1-44: Command template provides appropriate structure for workflow documentation.

The template establishes a clear, actionable format for commands with Overview, Steps, Error Handling, Checklist, and See Also sections. The structure is consistent with existing command files and provides useful scaffolding for contributors.

.cursor/commands/documentation/update-docs.md (1)

44-48: Documentation rules referenced in the See Also section exist.

The referenced rules @docs/docs.mdc and @docs/style.mdc are present in .cursor/rules/docs/.

.cursor/rules/security/secrets.mdc (2)

31-46: The CONFIG object API is correctly documented. Both CONFIG.BOT_TOKEN and CONFIG.database_url exist in src/tux/shared/config/settings.py with the correct casing and are used consistently throughout the codebase.


77-85: [rewritten comment]
[classification tag]

.cursor/commands/security/security-review.md (2)

51-55: All referenced security rules exist.

The three security rules referenced in the See Also section are present in .cursor/rules/security/: @security/patterns.mdc, @security/secrets.mdc, and @security/validation.mdc. Note: A fourth rule file (@security/dependencies.mdc) exists in the directory but is not currently referenced in this document.


9-13: Correct the description of uv run dev all—it does not check for vulnerabilities or outdated packages.

The command uv run dev all exists and is properly registered, but the security review documentation mischaracterizes its purpose. This command runs code quality checks (linting, formatting, type checking, docstrings, and pre-commit hooks), not security audits. It cannot replace dedicated dependency vulnerability scanning. For actual security checks, use uv pip compile --python-version 3.13 with a security audit tool, or refer to uv.lock directly for outdated packages. Reword this step to accurately reflect that it validates code quality rather than security.

Likely an incorrect or invalid review comment.

.cursor/rules/testing/async.mdc (2)

48-76: Fixtures verified and properly documented.

All referenced fixtures (pglite_engine, pglite_async_manager, db_service) are defined in tests/fixtures/database_fixtures.py and registered via pytest_plugins in conftest.py. The async patterns, dependencies, and scopes (session for manager, function for engine and service) match the documented examples exactly.


20-26: All markers, fixtures, and dependencies are correctly configured.

Verification confirms:

  • The unit marker is defined in pyproject.toml under [tool.pytest.ini_options] as "Unit tests with isolated components"
  • The marker is consistently used across 12 test files in the project
  • Fixtures db_service, pglite_engine, and pglite_async_manager are properly defined in tests/fixtures/database_fixtures.py
  • Both pytest-asyncio>=1.2.0 and pytest-timeout>=2.4.0 are in project dependencies
  • AsyncIO configuration is properly set with asyncio_mode = "auto" and appropriate fixture loop scopes
.cursor/rules/testing/coverage.mdc (1)

34-45: Commands uv run test all and uv run test html are correctly configured and functional.

Both test subcommands are properly wired in scripts/test/__init__.py and implement the documented behavior:

  • uv run test all runs pytest with coverage enabled (configured in pyproject.toml addopts with --cov=src/tux)
  • uv run test html runs pytest with --cov-report=html, generating coverage reports in htmlcov/index.html

The pytest-cov and pytest-html dependencies are already included in the project's test dependency group.

docs/content/developer/guides/creating-cursor-rules.md (1)

272-275: The template file reference at line 273 is correct and the file exists at .cursor/templates/rule-template.mdc.

.cursor/rules/modules/interactions.mdc (1)

169-190: All utility functions referenced in lines 171-179 and 186-189 are confirmed to exist in the codebase. validate_author (line 25), validate_interaction_data (line 53), and handle_callback_error (line 76) are properly defined in src/tux/ui/views/config/callbacks.py. The interactions.mdc rule accurately references these functions.

Likely an incorrect or invalid review comment.

.cursor/rules/modules/cogs.mdc (1)

218-223: Cross-references look good.

See Also section properly links to related module documentation and general coding standards.

.cursor/rules/security/validation.mdc (1)

1-190: Well-structured security validation guidance.

Documentation comprehensively covers input validation across command, interaction, database, and string domains with practical examples and clear anti-patterns. The reference to helper functions and SQLModel's automatic safeguards is accurate.

.cursor/rules/database/services.mdc (1)

192-197: Cross-references are consistent and appropriate.

See Also section properly links to controller, model, and standards documentation.

docs/content/developer/guides/creating-cursor-commands.md (2)

275-275: Verify template path reference is correct.

Line 275 uses a relative path to reference the command template: ../../../../.cursor/templates/command-template.md. Please verify this path resolves correctly from the docs/content/developer/guides/ directory. If the file structure differs, the path may need adjustment.


1-277: Comprehensive and well-structured guide for creating Cursor commands.

Documentation provides clear step-by-step guidance, practical examples, complete templates, and quality standards. The organization from quick start through maintenance workflow is logical and actionable. Validation integration with uv run rules validate is properly referenced.

.cursor/commands/discord/test-command.md (1)

1-48: Practical Discord command testing guide.

Documentation provides clear workflow for manual testing with comprehensive checklist. Steps appropriately cover startup verification, command execution with valid/invalid inputs, permission checks, logging, and response rendering. Covers the testing essentials without unnecessary verbosity.

.cursor/rules/error-handling/sentry.mdc (1)

1-132: Well-organized Sentry integration guidance.

Documentation clearly explains automatic capture with context, manual capture patterns, context setting helpers, automatic sanitization, and performance monitoring. The emphasis on using capture_exception_safe wrapper rather than direct SDK calls is appropriate. Anti-patterns appropriately discourage manual capture when error handler should handle it.

.cursor/rules/security/patterns.mdc (1)

1-178: Comprehensive security patterns reference.

Documentation appropriately covers input validation, permission checks, database security, and error handling with practical examples. The emphasis on generic user messages while logging detailed errors is a strong security practice. Parameterized query guidance via SQLModel is accurate. Cross-references to related security and error-handling documentation are appropriate.

.cursor/commands/testing/test-coverage.md (1)

1-46: Clear test coverage workflow guide.

Documentation provides practical steps for generating reports, analyzing coverage, and improving test coverage. Explicit coverage goals (80%+ overall, 100% on critical paths) provide clear targets. Checklist is comprehensive and verifiable. References to related rule documentation and other test commands are appropriate.

.pre-commit-config.yaml (2)

86-94: LGTM! Local hook configuration looks correct.

The validate-rules hook is properly configured with system language, correct file pattern matching for .cursor rules and commands, and pass_filenames: false since the CLI handles file discovery internally.


29-29: Verify the version downgrades are intentional.

Several hook versions have been downgraded:

  • yamlfix: 1.19.1 → 1.19.0
  • markdownlint-cli: v0.47.0 → v0.46.0
  • ruff: v0.14.10 → v0.14.7

If these are intentional (e.g., due to compatibility issues), consider adding a comment explaining the reason. Otherwise, these may have been accidentally reverted.

Also applies to: 44-44, 52-52, 57-57

.cursor/rules/security/dependencies.mdc (1)

1-101: LGTM! Well-structured dependency security documentation.

The rule file follows the MDC format correctly with proper frontmatter, clear good/bad examples, and actionable guidance for uv dependency management. The globs appropriately target pyproject.toml, uv.lock, and requirements files.

.cursor/rules/meta/cursor-rules.mdc (1)

1-160: Overall specification is well-structured.

The Cursor Rules Specification provides comprehensive guidance on rule types, MDC format, constraints, and validation criteria. The document follows its own standards and serves as a good reference for rule authors. Based on learnings, this aligns with AGENTS.md coding agent rules.

.cursor/rules/meta/cursor-commands.mdc (1)

1-108: Rest of the specification is well-documented.

The command type classification, file format requirements, invocation syntax, content requirements, and comparison with rules are all clear and useful for contributors.

Also applies to: 120-203

.cursor/rules/database/migrations.mdc (1)

1-249: Comprehensive Alembic migration documentation.

The guide covers migration creation, patterns (tables, columns, foreign keys, enums), safety practices, and anti-patterns effectively. Based on learnings, this aligns with the project's use of Alembic for database migrations.

.cursor/rules/modules/events.mdc (1)

1-100: Well-structured event handler documentation.

The guide covers event listeners, common events, organization patterns, and error handling effectively. The patterns align with the actual implementation in src/tux/services/handlers/event.py.

Also applies to: 109-265

.cursor/rules/database/models.mdc (1)

1-125: Comprehensive SQLModel documentation aligned with project patterns.

The guide effectively covers BaseModel inheritance, field definitions, relationships, and validation. Based on learnings, this aligns with using SQLModel for type-safe database operations and model-level validation.

Also applies to: 132-260

scripts/rules.py (2)

22-63: CLI structure and command registration look good.

The RulesCLI class properly inherits from BaseCLI, uses the command registry pattern, and the callback trick to force Typer into subcommand mode is a known workaround for single-command apps.


121-166: Validation logic is comprehensive and well-structured.

The description and content validation methods properly handle special cases (specs, references, docs rules) and provide clear error messages. Command validation checks for required sections with appropriate regex patterns.

Also applies to: 281-329

pyproject.toml (1)

66-66: LGTM! Script entry correctly registered.

The new rules script entry is properly configured and follows the existing pattern for CLI tools in this project. This enables the uv run rules command referenced throughout the documentation.

.cursor/rules/error-handling/logging.mdc (3)

1-5: Frontmatter correctly configured.

The rule frontmatter is properly structured with an appropriate glob pattern for Python files and correctly set to apply only when editing matching files.


149-155: All cross-referenced files in the "See Also" section exist in their expected locations.


18-18: Verify logging module references are accurate.

The documentation references loguru logger (line 18), CONFIG.LOG_LEVEL (line 93), and configure_testing_logging from tux.core.logging (line 102). Confirm these exist in the codebase.

Applies to: Lines 18, 89-104

.cursor/commands/database/reset.md (3)

32-33: Appropriate data loss warning.

The prominent warning about data deletion is well-placed and clearly communicates the destructive nature of the reset operation.


47-49: Verify referenced files exist.

Confirm the referenced rule (@database/migrations.mdc) and command files (/database-migration, /database-health) exist in the repository structure.


15-15: All documented database subcommands are implemented and properly registered in the scripts.db module:

  • reset() command in scripts/db/reset.py
  • status() command in scripts/db/status.py
  • health() command in scripts/db/health.py

All three are imported and added to the app via app.add_typer() in scripts/db/__init__.py. Documentation is accurate.

.cursor/commands/database/migration.md (2)

45-47: Cross-references align with PR structure.

The see-also references point to related database documentation files that are part of this PR, creating a cohesive documentation set.


11-11: No changes needed. The migration directory path src/tux/database/migrations/versions/ exists and is correctly referenced in the documentation.

.cursor/commands/discord/create-module.md (2)

22-24: Documentation aligns with project patterns.

The guidance correctly emphasizes hybrid commands and permission checks, consistent with established project patterns. Based on learnings, this aligns with the requirement to implement role-based permissions and use hybrid commands for Discord commands.


17-17: All referenced components exist in the codebase: BaseCog (src/tux/core/base_cog.py), ModerationCogBase (src/tux/modules/moderation/init.py), @requires_command_permission decorator (src/tux/core/decorators.py), and tux.ui.embeds module. The documentation references are accurate.

.cursor/commands/code-quality/lint.md (3)

57-59: All referenced commands and rules exist: /refactor and /review-existing-diffs commands are present in .cursor/commands/code-quality/, and @core/tech-stack.mdc rule exists in .cursor/rules/core/.


19-19: NumPy docstring format is properly configured in the project (pydoclint and pydocstyle both set to style = "numpy" in pyproject.toml). The lint.md documentation correctly reflects this as a project standard.


10-13: The dev all command is properly implemented in scripts/dev/all.py and registered in the dev command group. No issues found.

.cursor/commands/documentation/docs-serve.md (2)

51-53: All referenced files exist: @docs/zensical.mdc is located at .cursor/rules/docs/zensical.mdc, and both /generate-docs and /update-docs commands are present at .cursor/commands/documentation/generate-docs.md and .cursor/commands/documentation/update-docs.md respectively. The see-also section references are valid.


10-10: No changes needed.

Both verification points in the original comment have been confirmed:

  • The scripts.docs module does implement a serve subcommand (defined in scripts/docs/serve.py with @app.command(name="serve"))
  • Port 8000 is indeed the default (set as the default value for dev_addr parameter: "localhost:8000")

The uv run docs serve command documentation is accurate and complete.

.cursor/README.md (3)

18-42: Verify documented directory structure exists.

The README documents a comprehensive directory structure for rules and commands. Confirm these directories exist as documented:

  • Rules directories: core/, database/, modules/, testing/, docs/, security/, error-handling/, ui/, meta/
  • Commands directories: code-quality/, testing/, database/, discord/, security/, debugging/, error-handling/, documentation/, development/

62-62: All referenced documentation files exist at the specified paths. No action required.

  • rules/rules.mdc.cursor/rules/rules.mdc
  • creating-cursor-rules.mddocs/content/developer/guides/creating-cursor-rules.md
  • creating-cursor-commands.mddocs/content/developer/guides/creating-cursor-commands.md
  • AGENTS.md./AGENTS.md

73-74: Documentation links are valid. Both Cursor documentation URLs point to the correct resources and are accessible.

.cursor/commands/error-handling/add-error-handling.md (1)

1-47: Well-structured command documentation with clear guidance.

The error handling command provides practical step-by-step guidance and a comprehensive checklist. All referenced error-handling rules exist in this PR and cross-references are accurate.

.cursor/rules/error-handling/patterns.mdc (1)

1-163: Comprehensive error handling guidance aligned with best practices.

The patterns documentation correctly emphasizes custom exceptions from tux.shared.exceptions, proper error context preservation with from e, and separation of local vs. global error handlers. The examples and anti-patterns are clear and actionable.

.cursor/commands/development/setup-project.md (1)

1-61: Clear setup workflow with proper sequencing.

The setup guide follows a logical progression and references both Docker and database commands appropriately. The cross-references use consistent notation (@ for rules, / for commands).

.cursor/rules/testing/fixtures.mdc (1)

1-206: Comprehensive fixture patterns with proper scope and organization guidance.

The fixture documentation correctly describes scoping strategies (session for expensive setup, function for isolation), shows proper typing, and emphasizes cleanup patterns. The fixture dependency chain example clearly demonstrates composition.

.cursor/commands/code-quality/review-existing-diffs.md (1)

1-57: Clear code review workflow with actionable checklist.

The review guidance covers Tux-specific checks (database, tests, docs, scripts) and includes a comprehensive checklist. Cross-references to related linting, refactoring, and test commands are consistent with project structure.

.cursor/commands/database/health.md (1)

1-47: Practical database health check guide with clear diagnostic steps.

The health check command provides systematic troubleshooting steps from connection verification through operation testing. Cross-references to related database commands and rules are consistent.

.cursor/rules/core/tech-stack.mdc (3)

2-3: Good additions to frontmatter and workflow section.

The added description field and alwaysApply flag are appropriate. The development workflow examples effectively demonstrate the correct use of uv commands and discourage common anti-patterns like bypassing setup or using Python directly.


62-64: Database driver documentation is accurate.

The characterization of asyncpg being approximately 5x faster than psycopg aligns with documented performance benchmarks. Positioning asyncpg as primary and psycopg[binary,pool] as backup is a sensible choice for an async-first Discord bot that prioritizes concurrency and performance, particularly given the project's asyncio foundation.


122-144: Development workflow examples enforce project standards effectively.

The GOOD examples correctly show the required setup sequence (uv sync, environment configuration, quality checks, testing), and the BAD examples explicitly discourage common mistakes. This is pedagogically effective and aligns with the project's use of uv as the single entry point for all CLI operations.

.cursor/rules/modules/permissions.mdc (2)

7-156: Content and examples are accurate and well-structured.

The permission patterns, examples, and flow descriptions align with the Discord bot permission model used in the codebase (verified against the Purge cog context). The GOOD/BAD examples clearly demonstrate the decorator-based permission pattern, and the checking flow is logical and comprehensive.


1-156: All cross-referenced rule files are present.

The permissions.mdc file references @modules/commands.mdc, @modules/cogs.mdc, @database/models.mdc, and @rules.mdc—all of which exist in the .cursor/rules/ directory.

AGENTS.md (3)

141-182: Workflow and PR requirements are well-integrated and consistent.

The rules validation step is properly placed in the development workflow (step 4, between database and commit phases) and appropriately listed as a PR requirement. This aligns with the enforcement pattern described in the PR objectives (pre-commit hook + validation CLI).


60-64: Documentation updates provide valuable clarity on .cursor structure and database stack.

The project structure now clearly documents the .cursor directory organization, and the database stack explicitly mentions psycopg async for PostgreSQL async support. These additions improve clarity for developers setting up the project and understanding the async database architecture.

Also applies to: 98-98


10-32: All referenced documentation files and CLI configuration are properly in place. The .cursor/rules/rules.mdc master catalog exists, both developer guide files (creating-cursor-rules.md and creating-cursor-commands.md) are present, and the uv run rules validate command is correctly registered in pyproject.toml via scripts.rules:main. No changes required.

Comment on lines 17 to 24
```toml
[tool.pytest.ini_options.markers]
unit = "Unit tests (uses py-pglite)"
integration = "Integration tests (uses py-pglite)"
slow = "Slow tests (>5 seconds)"
database = "Tests requiring database access"
async = "Async tests"
```
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# Check the actual content of the markers.mdc file around the specified lines
cat -n .cursor/rules/testing/markers.mdc | sed -n '1,30p'

Repository: allthingslinux/tux

Length of output: 949


🏁 Script executed:

# Check lines around 107-108 to see the example usage
cat -n .cursor/rules/testing/markers.mdc | sed -n '100,115p'

Repository: allthingslinux/tux

Length of output: 510


🏁 Script executed:

# Check if pyproject.toml exists and what markers are defined there
if [ -f pyproject.toml ]; then
  cat -n pyproject.toml | grep -A 10 "tool.pytest.ini_options.markers"
fi

Repository: allthingslinux/tux

Length of output: 44


🌐 Web query:

pytest-asyncio marker naming convention what is the correct marker name

💡 Result:

The correct marker is pytest.mark.asyncio (e.g. @pytest.mark.asyncio). [1][2]

Sources:
[1] pytest-asyncio documentation — Markers.
[2] pytest-asyncio PyPI project page — Markers.


Fix async marker definition in TOML snippet.

The markers list defines async = "Async tests" (line 23), but the code example uses @pytest.mark.asyncio (line 107). The TOML snippet should be corrected to match the standard pytest-asyncio marker name:

asyncio = "Async tests"

Alternatively, if a custom async marker is intended, update the code example to use @pytest.mark.async instead.

🤖 Prompt for AI Agents
In .cursor/rules/testing/markers.mdc around lines 17 to 24, the TOML markers
section defines the pytest async marker as `async = "Async tests"` which doesn't
match the code example that uses `@pytest.mark.asyncio`; update the TOML key to
`asyncio = "Async tests"` so the marker name matches pytest-asyncio, or
alternatively change the code examples to use `@pytest.mark.async` if a custom
`async` marker is intended—pick one approach and make the TOML and code
consistent.

…tation

- Replaced the `uv run rules validate` command with `uv run ai validate-rules` for improved clarity and consistency in validation processes.
- Updated relevant documentation across multiple files to reflect the new command structure, ensuring developers have accurate guidance on validation procedures.
- Introduced a new `ai` command group to encapsulate AI-related tools and utilities, enhancing the organization of command functionalities.
- Removed the deprecated `rules.py` file, streamlining the codebase and focusing on the new validation approach.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (4)
scripts/ai/__init__.py (1)

10-12: Consider explicit naming for the subcommand group.

The add_typer call omits the name parameter. Since validate_rules.app is created with create_app() (no name), the subcommand will inherit the command name from @app.command(name="validate-rules"). This works but could be confusing if more commands are added to validate_rules.app later.

If this module is intended to hold only the validate-rules command, the current approach is fine. If you plan to add more commands, consider either:

  1. Passing name="validate-rules" explicitly here, or
  2. Giving validate_rules.app a name in its create_app() call
scripts/ai/validate_rules.py (3)

188-196: Consider more robust path matching for special cases.

The special case detection uses string matching on paths (e.g., "meta/" in str(file_path), "ui/cv2.mdc" in str(file_path)). This works but could fail on Windows or with unexpected path structures.

Consider using Path.parts or Path.match() for more robust matching:

🔎 Proposed improvement
-    is_spec = "meta/" in str(file_path)
-    is_docs_rule = "docs/" in str(file_path)
-    is_large_reference = "ui/cv2.mdc" in str(file_path)
+    is_spec = "meta" in file_path.parts
+    is_docs_rule = "docs" in file_path.parts
+    is_large_reference = file_path.match("**/ui/cv2.mdc")

41-50: Edge case in frontmatter closing check.

Line 44 checks "---\n" not in content[4:], which assumes the opening --- is exactly 3 characters. If there's a BOM or extra whitespace, this could give false positives. The subsequent regex match (line 47) is more robust and will catch these cases, so this is low risk.

🔎 Potential simplification

Consider relying solely on the regex match for validation:

 def _check_rule_frontmatter(...) -> tuple[list[str], str | None]:
     ...
     if not content.startswith("---"):
         errors.append(f"{file_path}: Rule must start with frontmatter (---)")
+        return errors, None

-    if "---\n" not in content[4:]:
-        errors.append(f"{file_path}: Rule must have closing frontmatter (---)")
-
     frontmatter_match = re.match(r"^---\n(.*?)\n---\n", content, re.DOTALL)
     if not frontmatter_match:
-        errors.append(f"{file_path}: Invalid frontmatter format")
+        errors.append(f"{file_path}: Invalid or missing closing frontmatter (---)")
         return errors, None

189-190: Consider error handling for file read operations.

file_path.read_text() can raise OSError or UnicodeDecodeError. While unlikely in normal operation, adding a try-except would make the tool more resilient:

🔎 Proposed improvement
 def _validate_rule(file_path: Path) -> list[str]:
     ...
     errors: list[str] = []
-    content = file_path.read_text(encoding="utf-8")
+    try:
+        content = file_path.read_text(encoding="utf-8")
+    except OSError as e:
+        return [f"{file_path}: Failed to read file: {e}"]
+    except UnicodeDecodeError as e:
+        return [f"{file_path}: Invalid encoding: {e}"]

Apply similar handling in _validate_command.

Also applies to: 248-249

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 94abd23 and f1bb4f8.

📒 Files selected for processing (8)
  • .pre-commit-config.yaml
  • AGENTS.md
  • docs/content/developer/guides/creating-cursor-commands.md
  • docs/content/developer/guides/creating-cursor-rules.md
  • pyproject.toml
  • scripts/__init__.py
  • scripts/ai/__init__.py
  • scripts/ai/validate_rules.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/content/developer/guides/creating-cursor-rules.md
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Use strict type hints with Type | None instead of Optional[Type]
Use NumPy docstrings for documenting functions and classes
Prefer absolute imports; relative imports allowed only within the same module
Organize imports in order: stdlib → third-party → local
Use 88 character line length
Use snake_case for functions and variables, PascalCase for classes, UPPER_CASE for constants
Always add imports to the top of the file unless absolutely necessary
Use async/await for I/O operations
Use custom exceptions for business logic with context logging and meaningful user messages
Use Pydantic for data validation
Keep files to a maximum of 1600 lines
Use one class or function per file when possible
Use descriptive filenames
Add appropriate logging to services and error handlers

Files:

  • scripts/ai/__init__.py
  • scripts/ai/validate_rules.py
  • scripts/__init__.py
🧠 Learnings (5)
📚 Learning: 2025-12-21T20:54:29.808Z
Learnt from: CR
Repo: allthingslinux/tux PR: 0
File: .cursor/rules/rules.mdc:0-0
Timestamp: 2025-12-21T20:54:29.808Z
Learning: Follow the coding agent rules defined in AGENTS.md

Applied to files:

  • AGENTS.md
📚 Learning: 2025-12-28T16:20:43.646Z
Learnt from: CR
Repo: allthingslinux/tux PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T16:20:43.646Z
Learning: Applies to **/database/**/*.py : Use SQLModel for type-safe database operations

Applied to files:

  • AGENTS.md
📚 Learning: 2025-12-28T16:20:43.646Z
Learnt from: CR
Repo: allthingslinux/tux PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T16:20:43.646Z
Learning: Applies to **/alembic/**/*.py : Use Alembic for database migrations

Applied to files:

  • AGENTS.md
📚 Learning: 2025-12-28T16:20:43.646Z
Learnt from: CR
Repo: allthingslinux/tux PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T16:20:43.646Z
Learning: Applies to **/database/**/*.py : Optimize database queries

Applied to files:

  • AGENTS.md
📚 Learning: 2025-12-28T16:20:43.646Z
Learnt from: CR
Repo: allthingslinux/tux PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T16:20:43.646Z
Learning: Applies to **/database/**/*.py : Use transactions for multi-step database operations

Applied to files:

  • AGENTS.md
🧬 Code graph analysis (2)
scripts/ai/__init__.py (4)
scripts/ai/validate_rules.py (1)
  • validate_rules (329-405)
scripts/core.py (1)
  • create_app (35-66)
typings/typer/main.pyi (1)
  • add_typer (31-32)
scripts/__init__.py (1)
  • main (27-29)
scripts/ai/validate_rules.py (1)
scripts/core.py (1)
  • create_app (35-66)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Run All Tests (3.13.8)
  • GitHub Check: Sourcery review
🔇 Additional comments (9)
.pre-commit-config.yaml (2)

86-94: Well-structured pre-commit hook for Cursor validation.

The hook configuration correctly:

  • Uses system language to leverage the local uv installation
  • Passes directory arguments explicitly
  • Scopes file matching to .cursor/(rules|commands)/ paths
  • Uses pass_filenames: false since the validator processes directories

29-29: Verify intentional version downgrades.

Several hook versions were downgraded:

  • yamlfix: 1.19.1 → 1.19.0
  • markdownlint-cli: v0.47.0 → v0.46.0
  • ruff-pre-commit: v0.14.10 → v0.14.7

If these are intentional (e.g., to avoid bugs in newer versions), consider adding a brief comment. Otherwise, these may have been accidentally reverted.

Also applies to: 44-44, 52-52, 57-57

docs/content/developer/guides/creating-cursor-commands.md (1)

1-277: Comprehensive and well-structured documentation.

The guide provides clear, actionable steps for creating Cursor commands with appropriate templates, examples, and validation instructions. The cross-references to related documentation are helpful.

AGENTS.md (1)

10-33: Clear Cursor integration documentation.

The new section provides a good overview of the rules/commands system with links to detailed documentation. The tip admonition directing users to domain-specific rules is helpful.

scripts/__init__.py (1)

8-8: Clean CLI group registration.

The ai command group is properly imported and registered following the existing pattern for other command groups. Alphabetical ordering is maintained.

Also applies to: 18-18

pyproject.toml (1)

66-66: Correct script entry registration.

The new ai script entry follows the established pattern and correctly points to scripts.ai:main.

scripts/ai/__init__.py (1)

1-17: Well-structured command group module.

The module follows project patterns with NumPy docstrings and proper CLI wiring. The entry point is correctly defined for the pyproject.toml script.

scripts/ai/validate_rules.py (2)

328-344: Well-designed CLI command with sensible defaults.

The command uses Annotated with Option for clear parameter documentation, and the default paths align with the project's .cursor/ structure. The NumPy docstring is complete.


363-395: Good defensive handling for missing directories.

The validation gracefully handles missing directories with warnings rather than errors, which is appropriate for a validation tool that might run in different contexts.

…-quality Python code

- Added a new `deslop` command to guide developers in producing consistent, maintainable code while adhering to Tux project standards.
- Included detailed steps for a research-first protocol, writing consistent code, and following Python standards to avoid common anti-patterns.
- Established a checklist for self-audit and error handling to ensure code quality and adherence to best practices.
… rule files

- Enhanced the frontmatter validation logic to provide clearer error messages for invalid or missing closing frontmatter.
- Added error handling for file reading operations to catch and report issues related to file access and encoding.
- Refactored checks for special cases in rule file paths to improve clarity and maintainability.
- Changed the validation command from `uv run rules validate` to `uv run ai validate-rules` in AGENTS.md to align with recent command structure updates.
- Ensured that the documentation reflects the latest changes in the validation process for improved clarity and guidance.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
scripts/ai/validate_rules.py (1)

176-237: Hardcoded file exception for size limit.

Line 201 hardcodes **/ui/cv2.mdc as a large reference exception. Consider extracting this to a constant or configuration if more exceptions are needed in the future.

🔎 Suggested refactor
+# Files exempt from the 500-line limit
+LARGE_FILE_EXCEPTIONS: set[str] = {"**/ui/cv2.mdc"}
+
+
 def _validate_rule(file_path: Path) -> list[str]:
     # ...
     is_spec = "meta" in file_path.parts
     is_docs_rule = "docs" in file_path.parts
-    is_large_reference = file_path.match("**/ui/cv2.mdc")
+    is_large_reference = any(file_path.match(pattern) for pattern in LARGE_FILE_EXCEPTIONS)
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f1bb4f8 and 10f239e.

📒 Files selected for processing (4)
  • .cursor/commands/code-quality/deslop.md
  • .cursor/commands/deslop.md
  • AGENTS.md
  • scripts/ai/validate_rules.py
💤 Files with no reviewable changes (1)
  • .cursor/commands/deslop.md
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Use strict type hints with Type | None instead of Optional[Type]
Use NumPy docstrings for documenting functions and classes
Prefer absolute imports; relative imports allowed only within the same module
Organize imports in order: stdlib → third-party → local
Use 88 character line length
Use snake_case for functions and variables, PascalCase for classes, UPPER_CASE for constants
Always add imports to the top of the file unless absolutely necessary
Use async/await for I/O operations
Use custom exceptions for business logic with context logging and meaningful user messages
Use Pydantic for data validation
Keep files to a maximum of 1600 lines
Use one class or function per file when possible
Use descriptive filenames
Add appropriate logging to services and error handlers

Files:

  • scripts/ai/validate_rules.py
🧠 Learnings (6)
📓 Common learnings
Learnt from: CR
Repo: allthingslinux/tux PR: 0
File: .cursor/rules/rules.mdc:0-0
Timestamp: 2025-12-21T20:54:29.808Z
Learning: Follow the coding agent rules defined in AGENTS.md
📚 Learning: 2025-12-21T20:54:29.808Z
Learnt from: CR
Repo: allthingslinux/tux PR: 0
File: .cursor/rules/rules.mdc:0-0
Timestamp: 2025-12-21T20:54:29.808Z
Learning: Follow the coding agent rules defined in AGENTS.md

Applied to files:

  • AGENTS.md
📚 Learning: 2025-12-28T16:20:43.646Z
Learnt from: CR
Repo: allthingslinux/tux PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T16:20:43.646Z
Learning: Applies to **/database/**/*.py : Use SQLModel for type-safe database operations

Applied to files:

  • AGENTS.md
📚 Learning: 2025-12-28T16:20:43.646Z
Learnt from: CR
Repo: allthingslinux/tux PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T16:20:43.646Z
Learning: Applies to **/alembic/**/*.py : Use Alembic for database migrations

Applied to files:

  • AGENTS.md
📚 Learning: 2025-12-28T16:20:43.646Z
Learnt from: CR
Repo: allthingslinux/tux PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T16:20:43.646Z
Learning: Applies to **/database/**/*.py : Optimize database queries

Applied to files:

  • AGENTS.md
📚 Learning: 2025-12-28T16:20:43.646Z
Learnt from: CR
Repo: allthingslinux/tux PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T16:20:43.646Z
Learning: Applies to **/database/**/*.py : Use transactions for multi-step database operations

Applied to files:

  • AGENTS.md
🪛 LanguageTool
.cursor/commands/code-quality/deslop.md

[grammar] ~1-~1: Ensure spelling is correct
Context: # Deslop ## Overview Produce high-quality Python co...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Run All Tests (3.13.8)
  • GitHub Check: Sourcery review
🔇 Additional comments (11)
.cursor/commands/code-quality/deslop.md (3)

1-6: LGTM! Well-structured command guide.

The "Deslop" term is intentional (removing "slop" patterns from AI-generated code) and the static analysis spelling warning is a false positive. The document provides comprehensive, actionable guidance for maintaining code quality.


29-36: Python standards section aligns with project coding guidelines.

The documented standards (Type | None, NumPy docstrings, 88-char line length, naming conventions) correctly reflect the project's coding guidelines.


140-148: All cross-referenced commands and rules exist in the repository. No issues found with the references in the "See Also" section.

AGENTS.md (4)

10-33: LGTM! Well-structured Cursor Rules & Commands section.

This new section provides clear documentation with validation commands, links to guides, and a helpful tip about detailed rules. The command uv run ai validate-rules is consistently referenced throughout the document.


134-138: Past review comment addressed.

The command reference is now correctly uv run ai validate-rules, matching other references in this file.


252-255: Past review comment addressed.

The troubleshooting section now correctly uses uv run ai validate-rules.


98-98: Incorrect driver terminology in stack description.

The stack should reference "psycopg" (not "psycopg async"). The codebase uses psycopg[binary,pool]>=3.2.9 as the PostgreSQL driver, which natively supports async operations via SQLAlchemy's create_async_engine. The term "psycopg async" is imprecise; asyncpg is not used as the driver (only asyncpg-stubs exists for type checking). Update line 98 to: **Stack:** SQLModel (ORM) • Alembic (migrations) • PostgreSQL (psycopg)

Likely an incorrect or invalid review comment.

scripts/ai/validate_rules.py (4)

1-18: LGTM! Well-organized module structure.

Module docstring, imports (stdlib → third-party → local), and app initialization follow project standards.


21-75: LGTM! Robust frontmatter validation.

The function correctly handles edge cases:

  • Missing frontmatter start
  • Invalid/missing closing frontmatter
  • Array format detection for globs
  • Quoted pattern detection

Good use of early returns with error context.


338-415: LGTM! Well-implemented CLI command.

The validate_rules function:

  • Uses Annotated with Option for Typer integration
  • Has complete NumPy-style docstring
  • Handles missing directories gracefully with warnings
  • Provides clear console output with rich formatting
  • Correctly exits with code 1 on validation failure

190-195: Good error handling for file operations.

Catching both OSError and UnicodeDecodeError separately provides clear, specific error messages for different failure modes.

…tation

- Changed the command for creating migrations from `uv run db migrate-dev` to `uv run db dev` for consistency.
- Updated Docker service startup commands from `uv run docker up` to `docker compose up -d` in both the setup-project and docker-up documentation.
- Revised related command references for clarity and accuracy in the documentation.
…tion

- Introduced a set of exempted files from the 500-line limit, specifically for `ui/cv2.mdc`.
- Updated the validation logic to check against this set, improving handling of large reference files in the validation process.
@kzndotsh kzndotsh merged commit dbbbd98 into main Dec 30, 2025
29 checks passed
@kzndotsh kzndotsh deleted the feat/agents branch December 30, 2025 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants