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.

- 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.
@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://7d3f5774-tux-docs.allthingslinux.workers.dev 7d3f5774-5d9d-463f-a15e-e0860e1bd3c9 Preview: tux@544a6f6c907e955967ee9e3c6de81961a38907c8 on 1101/merge by kzndotsh (run 160)

@sentry
Copy link

sentry bot commented Dec 7, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 40.13%. Comparing base (40fc395) to head (1f73363).
✅ All tests successful. No failed tests found.

❌ Your project check has failed because the head coverage (40.13%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1101   +/-   ##
=======================================
  Coverage   40.13%   40.13%           
=======================================
  Files         205      205           
  Lines       14628    14628           
  Branches     1722     1722           
=======================================
  Hits         5871     5871           
  Misses       8757     8757           

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

…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.
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