Skip to content

Conversation

@dcodesdev
Copy link
Collaborator

Summary

Adds a new shuttle ai rules command that generates AI coding assistant configuration files with Shuttle-specific development rules and best practices. This helps developers get better AI assistance when working on Shuttle projects by providing context-aware rules to popular AI coding tools.

Changes

  • New ai rules subcommand: Allows developers to generate AI assistant rules files for their preferred platform
  • Multi-platform support: Supports 5 AI coding assistants:
    • Cursor (.cursor/rules/shuttle.mdc)
    • Claude Code (CLAUDE.md)
    • Windsurf (.windsurf/rules/shuttle.md)
    • Gemini CLI (GEMINI.md)
    • Codex CLI (AGENTS.md)
  • Interactive mode: If no platform flag is provided, presents an interactive selection menu
  • Smart file handling:
    • Overwrites existing rules files for directory-based configs (Cursor, Windsurf)
    • Appends to existing files for top-level markdown configs (Claude, Gemini, Codex)
    • Prompts for confirmation before overwriting/appending
  • Comprehensive rules: Includes best practices for:
    • Core setup with #[shuttle_runtime::main]
    • Database configuration (shared DB vs AWS RDS)
    • Secrets management
    • Static assets configuration
    • Development workflow

Usage

# Interactive mode - select platform from menu
shuttle ai rules

# Generate for specific platform
shuttle ai rules --cursor
shuttle ai rules --claude
shuttle ai rules --windsurf
shuttle ai rules --gemini
shuttle ai rules --codex

Technical Details

  • Rules content is embedded at compile time using include_str! from ai-rules.md
  • New module cargo-shuttle/src/ai.rs handles all AI rules logic
  • Uses dialoguer crate for interactive CLI prompts
  • Platform-specific file paths and behaviors are encapsulated in the AiPlatform enum

Testing

Tested all platforms:

  • ✓ Interactive mode selection
  • ✓ Platform-specific flags
  • ✓ File creation in correct locations
  • ✓ Overwrite/append confirmation prompts
  • ✓ Directory creation for nested paths

🤖 Generated with Claude Code

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

Adds shuttle ai rules command that generates AI coding assistant configuration files with Shuttle-specific development rules for 5 platforms (Cursor, Claude Code, Windsurf, Gemini CLI, Codex CLI).

Key Changes:

  • New ai-rules.md containing Shuttle best practices and development guidelines
  • Interactive platform selection with dialoguer crate when no flag provided
  • Smart append vs overwrite behavior: directory-based configs overwrite, top-level markdown files append
  • User confirmation prompts before modifying existing files
  • Platform-specific file paths encapsulated in AiPlatform enum

Implementation Notes:

  • Rules content embedded at compile time via include_str! macro
  • Mutually exclusive CLI flags ensure single platform selection
  • All command integration follows existing patterns in the codebase

Confidence Score: 4/5

  • This PR is safe to merge with minor style improvements recommended
  • The implementation is solid and follows existing patterns. The logic is straightforward with proper error handling and user confirmations. Two minor issues: missing function documentation per custom instructions, and a capitalization helper that could handle Unicode better. No functional bugs detected.
  • cargo-shuttle/src/ai.rs could benefit from adding doc comments to public functions per custom instructions

Important Files Changed

File Analysis

Filename Score Overview
ai-rules.md 4/5 New markdown file containing Shuttle-specific development rules and best practices for AI coding assistants
cargo-shuttle/src/ai.rs 4/5 New module implementing AI rules command with platform selection, file writing, and user confirmation logic
cargo-shuttle/src/args.rs 5/5 Added AiCommand and AiRulesArgs with mutually exclusive platform flags for the new shuttle ai rules command
cargo-shuttle/src/lib.rs 5/5 Integrated new AI module and added command handler for Command::Ai that delegates to ai::handle_ai_rules

4 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment on lines 55 to 56
/// Handle the `ai rules` command
pub fn handle_ai_rules(args: &AiRulesArgs, working_directory: &Path) -> Result<()> {
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Missing doc comment explaining the purpose of this function

According to custom instructions, functions should have comments explaining their purpose, especially for new functionality.

Context Used: Context from dashboard - Include comments explaining the purpose of functions, especially for new or complex functionality. (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: cargo-shuttle/src/ai.rs
Line: 55:56

Comment:
**style:** Missing doc comment explaining the purpose of this function

According to custom instructions, functions should have comments explaining their purpose, especially for new functionality.

**Context Used:** Context from `dashboard` - Include comments explaining the purpose of functions, especially for new or complex functionality. ([source](https://app.greptile.com/review/custom-context?memory=fe8549ea-5239-4b00-a674-867d405455c8))

How can I resolve this? If you propose a fix, please make it concise.

) && file_path.exists();

// Check if file already exists
if file_path.exists() {
Copy link
Contributor

Choose a reason for hiding this comment

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

style: String capitalization logic assumes ASCII first character. Use to_uppercase() instead for proper Unicode handling.

Suggested change
if file_path.exists() {
action.chars().next().map(|c| c.to_uppercase().collect::<String>()).unwrap_or_default() + &action[1..]
Prompt To Fix With AI
This is a comment left during a code review.
Path: cargo-shuttle/src/ai.rs
Line: 130:130

Comment:
**style:** String capitalization logic assumes ASCII first character. Use `to_uppercase()` instead for proper Unicode handling.

```suggestion
                action.chars().next().map(|c| c.to_uppercase().collect::<String>()).unwrap_or_default() + &action[1..]
```

How can I resolve this? If you propose a fix, please make it concise.

@jonaro00
Copy link
Member

Based on what I heard from Nathan, it seems like most AI tools will respect agents.md nowadays, so maybe the list of choices can be reduced (please fact check).

Thus, is seems we are aiming to call the command generate agents (expanding the current generate subcommand) in a future update, so maybe we want to call it that now already.

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.

3 participants