Claude Code Cookbook

repository·main·Indexed 22 days ago

https://github.com/wasabeef/claude-code-cookbook

A plugin system for Claude Code that provides custom slash commands, expert role presets, and automated workflow hooks. It includes 39 commands across categories such as PR management, code quality, refactoring, planning, and dependency management. It also features specialized expert roles (e.g., security, architect, performance) that can be run in normal or independent sub-agent modes.

Tokens
132.4K
Snippets
287
Records
546
Agent score
58%

What's inside Claude Code Cookbook

  1. How the semantic-commit command detects project language

    main

    The semantic-commit command automatically determines whether to generate commit messages in Portuguese (pt) or English (en) using a scoring algorithm. It analyzes several signals to decide the language:

    1. CommitLint Configuration (+3 points): If subject-case is disabled (set to [0]) in commitlint.config.*, it strongly suggests Portuguese support.
    2. Git Log Analysis (up to +2 points): It checks the last 20 commits. If a significant portion contains Portuguese linguistic markers (e.g., ção, ões, agem), points are awarded.
    3. README.md Content (+1 point): It scans the first few lines of the README.md for Portuguese markers.
    4. Changed Files Content (+1 point): It scans the git diff of current changes for Portuguese comments or strings.

    Threshold: A score of 3 or more triggers Portuguese mode (pt). Otherwise, it defaults to English (en).

    # Example of scoring logic (conceptual)
    # 3 points or more = Portuguese mode
    # Less than 3 = English mode
  2. Understand the /smart-review suggestion logic and priorities

    main

    The /smart-review command uses a hierarchical logic to determine which roles to suggest. It looks at file extensions, directory structures, and content patterns (like error logs or security keywords).

    Role Priority Order

    When multiple roles are detected, the command prioritizes them in this order:

    1. Security: Authentication, authorization, and encryption.
    2. Critical Errors: System crashes or data loss.
    3. Architecture: Large-scale changes and technology selection.
    4. Performance: User experience and optimization.
    5. Frontend/Mobile: UI/UX improvements.
    6. QA: Quality assurance and testing.

    When to use role-debate

    The command will recommend the role-debate format instead of standard roles when:

    • Three or more roles are relevant to the context.
    • There is a clear trade-off required (e.g., Security vs. Performance).
    • Significant architectural changes are involved.
    • The context affects both mobile and web platforms.
  3. Understand how /smart-review selects roles

    main

    The /smart-review command uses a priority-based logic to determine which roles to recommend based on the context detected:

    Role Mapping Logic

    • frontend: package.json, *.tsx, *.jsx, *.css, *.scss
    • architect: Dockerfile, docker-compose.yml, *.yaml
    • qa: *.test.js, *.spec.ts, test/, __tests__/
    • performance: *.rs, Cargo.toml, performance/, webpack.config.js, vite.config.js
    • security: auth.js, security.yml, .env, config/auth/, jwt.js, api/auth/
    • mobile: mobile/, *.swift, *.kt, react-native/
    • analyzer: Stack traces, error.log, crash.log, or specific issues like memory leak or SQL injection.

    Priority Order

    When multiple roles are applicable, the system prioritizes them in this order:

    1. Security (Authentication, encryption)
    2. Critical Errors (Outages, data loss)
    3. Architecture (Large-scale changes)
    4. Performance (UX impact)
    5. Frontend/Mobile (UI/UX)
    6. QA (Testing)
  4. The Sequential Thinking process model

    main

    When the sequential-thinking skill is active, Claude follows a structured cognitive lifecycle to arrive at an optimal solution:

    1. Initial Analysis: Decomposing the problem and establishing a basic understanding.
    2. Hypothesis Generation: Formulating potential solutions or explanations.
    3. Verification and Revision: Testing hypotheses against constraints and revising them based on findings.
    4. Branching and Exploration: Simultaneously exploring multiple different solution paths or "what-if" scenarios.
    5. Integration and Conclusion: Synthesizing the explored paths into a final, optimal recommendation or solution.
  5. Language-specific documentation styles for /update-doc-string

    main

    The /update-doc-string command applies specific formatting rules based on the programming language detected or specified:

    LanguageDefault StylePrefixExample Format
    Pythongoogle"""PEP 257 compliant docstrings
    JavaScriptjsdoc/**JSDoc style
    TypeScripttsdoc/**TSDoc style
    Gogodoc//Go standard comments
    Rustrustdoc///Rustdoc style
    Dartdartdoc///Dartdoc style

    Prohibitions

    • No code changes: The command must only modify documentation, never the logic.
    • No speculation: Do not guess implementation details.
    • No type removal: Do not modify or remove existing type annotations.
    # Python (PEP 257) Example
    def calculate_total(items: List[Item]) -> float:
        """Calcular el monto total para una lista de elementos. (30-60 characters)
    
        Multiplica el precio y cantidad de cada elemento y devuelve
        el total con impuestos. (50-200 characters)
    
        Args:
            items: Lista de elementos a calcular
    
        Returns:
            Monto total con impuestos
    
        Generado por Claude 🤖
        """
  6. Automatic generation features in Spec Mode

    main

    When using the /spec command, Kiro automatically handles several high-fidelity development tasks:

    • Mermaid diagrams: Generates architecture and data flow diagrams within design.md.
    • TypeScript interfaces: Creates type definitions based on the design specifications.
    • Best practices: Automatically incorporates security and performance measures into the implementation plan.
    • Quality checkpoints: Sets phase-specific quality standards and includes automated checks for things like OWASP Top 10 countermeasures and code standards.
  7. Use multi-role modes for complex tasks

    main

    When a problem spans multiple domains or requires higher-level reasoning, use these advanced interaction modes:

    Parallel Analysis (multi-role)

    Use this to evaluate a problem from multiple professional perspectives simultaneously or to create integrated improvement plans. Example: /multi-role security,performance

    Discussion & Trade-offs (role-debate)

    Use this when there are divided opinions on technology selection or when you need to hear debates between different specialized perspectives to make a design decision. Example: /role-debate security,performance

    Automatic Proposal (smart-review)

    Use this if you are a beginner, are feeling indecisive, or simply do not know which role is optimal for your current situation. It automatically proposes the best approach. Example: /smart-review

  8. Calculate and judge AI prompt quality scores

    main

    Prompt quality is measured using a weighted scoring system based on category scores, penalties for critical issues, and bonuses for advanced features.

    Scoring Formula: Score final = Score base + Bônus - Penalidades

    • Score base: Σ(Score de cada categoria × Pontuação) / 100
    • Penalties (Fatal Problems):
      • Level 1: -20 points/case
      • Level 2: -10 points/case
      • Level 3: -5 points/case
    • Bonuses:
      • Automation support: +5 points
      • Learning function implementation: +5 points
      • Proven improvement cases: +5 points

    Quality Thresholds:

    • 95-100: World-class standard (industry recommended)
    • 90-94: Excellent (production ready)
    • 80-89: Good (operable with minor improvements)
    • 70-79: Normal (improvement needed)
    • 60-69: Requires improvement (substantial correction needed)
    • 50-59: Requires substantial correction (fundamental revision needed)
    • ≤ 49: Prohibited for use (complete redesign required)
  9. Analyze dependency update risks

    main

    The skill categorizes dependency updates into three risk levels to help you decide how to proceed:

    Risk LevelIconCriteria
    Safe🟢Patch version upgrades (e.g., 0.1.20.1.3), bug fixes only, guaranteed backward compatibility.
    Caution🟡Minor version upgrades (e.g., 0.1.00.2.0), new features added, or deprecation warnings.
    Dangerous🔴Major version upgrades (e.g., 1.x.y2.0.0), breaking changes, API removals, or trait bound changes.
  10. The three phases of Spec Mode development

    main

    Spec Mode operates through three distinct, interactive phases. Each phase requires user discussion and approval before moving to the next and generating a permanent documentation file.

    1. Phase 1: Requirements Discovery: Expands minimal input into detailed user stories and structured requirements using EARS notation.
      • Output: requirements.md (Requirement definitions).
    2. Phase 2: Design Exploration: Analyzes the existing codebase and proposes architecture, including Mermaid diagrams and TypeScript interfaces.
      • Output: design.md (Architecture and interface design).
    3. Phase 3: Implementation Planning: Generates a strategic plan including security best practices, quality checkpoints, and an optimized implementation order.
      • Output: tasks.md (Implementation plan and task list).
  11. Use multi-role patterns for complex problems

    main

    For problems that span multiple domains or require integrated perspectives, use these advanced role patterns instead of a single role:

    Parallel Analysis (multi-role)

    Use this when you need an integrated improvement plan or want to see how different professional perspectives overlap or contradict.

    • Example: /multi-role security,performance

    Discussion & Trade-offs (role-debate)

    Use this when you need to make a design decision involving trade-offs between specialized fields (e.g., choosing between security and performance).

    • Example: /role-debate security,performance

    Automatic Proposal (smart-review)

    Use this when you are a beginner or are completely unsure which role is optimal for your current situation.

    • Example: /smart-review
  12. Understand dependency update risk levels

    main

    When updating dependencies, Claude categorizes the risk level as follows:

    • Safe (🟢): Patch version upgrades (e.g., 1.2.31.2.4), bug fixes only, and guaranteed backward compatibility.
    • Caution (🟡): Minor version upgrades (e.g., 1.2.31.3.0), new features added, or deprecation warnings.
    • Dangerous (🔴): Major version upgrades (e.g., 1.2.32.0.0), breaking changes, or API removals/modifications.