Skip to content

feat: implement missing ddx patterns command #23

@mehdipiraee

Description

@mehdipiraee

Summary

The README documents ddx patterns commands that don't exist in the CLI implementation, causing user confusion and broken workflows.

Problem

The README clearly documents these commands under "Resource Commands":

ddx patterns list          # List available patterns
ddx patterns apply <name>  # Apply pattern to project

However, running these commands results in:

$ ddx patterns --help
Error: unknown command "patterns" for "ddx"

Documentation vs Implementation Gap

README Claims:

  • ddx patterns list - List available patterns ❌
  • ddx patterns apply <name> - Apply pattern to project ❌

CLI Actually Has:

  • ddx list - Lists all resources (templates, patterns, prompts, etc.) ✅
  • ddx apply <name> - Apply any resource ✅

Root Cause Analysis

Looking at the codebase:

  • ddx prompts command IS implemented (prompts.go, factory functions, registration)
  • ddx templates command is NOT implemented (tracked in feat: implement missing ddx templates command #22)
  • ddx patterns command is NOT implemented (no patterns.go, no factory functions)

Only the prompts resource command was actually built - templates and patterns were documented but never implemented.

Expected Implementation

Following the same pattern as ddx prompts:

  1. Create cli/cmd/patterns.go with:

    func runPatternsList(cmd *cobra.Command, args []string) error
    func runPatternsShow(cmd *cobra.Command, args []string) error
  2. Add factory functions in cli/cmd/command_factory_commands.go:

    func (f *CommandFactory) newPatternsListCommand() *cobra.Command
    func (f *CommandFactory) newPatternsShowCommand() *cobra.Command
  3. Register commands in cli/cmd/command_factory.go:

    patternsCmd := &cobra.Command{
        Use:     "patterns",
        Short:   "Manage code patterns",
        Aliases: []string{"pattern"},
    }
    patternsCmd.AddCommand(f.newPatternsListCommand())
    patternsCmd.AddCommand(f.newPatternsShowCommand())
    rootCmd.AddCommand(patternsCmd)

User Impact

Current Workaround:
Users must use generic commands:

  • ddx list (shows all resources mixed together)
  • ddx apply pattern-name

With Implementation:
Users can use documented, intuitive commands:

  • ddx patterns list (shows only code patterns)
  • ddx patterns show <name> (display pattern content)

Use Cases for Patterns

Code patterns are reusable solutions for common programming tasks:

  • Error handling patterns
  • Authentication patterns
  • Database connection patterns
  • API response patterns
  • Testing patterns
  • Logging patterns

Having dedicated commands makes these much more discoverable and usable.

Acceptance Criteria

  • ddx patterns --help shows help text
  • ddx patterns list lists available patterns from library/patterns/
  • ddx patterns list --search <term> filters patterns
  • ddx patterns show <name> displays pattern content
  • Commands follow same pattern as ddx prompts
  • Error handling for missing patterns directory
  • Proper test coverage

Related Issues

This is part of a broader documentation-implementation gap:

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions