Skip to content

Conversation

@sebyx07
Copy link
Collaborator

@sebyx07 sebyx07 commented Jan 25, 2026

Summary

  • Adds automatic coding style guide generation from CLAUDE.md and convention files
  • Generates concise (~600 words) guide capturing workflow (TDD) and code style conventions
  • Injects guide into planning and work prompts to ensure consistent coding style
  • Preserves coding-style.md across runs to save tokens

Test plan

  • Run pytest tests/core/test_prompts_coding_style.py - tests for the prompt
  • Run pytest tests/core/test_state_file_ops.py - tests for save/load coding style
  • Run pytest tests/core/test_state_backup.py - tests for cleanup preserving coding-style.md
  • Run pytest tests/core/test_prompts_planning.py - tests for coding style in planning prompt
  • Run pytest tests/core/test_prompts_working.py - tests for coding style in work prompt
  • Run full test suite: pytest tests/ - all 4539 tests pass
  • Run ruff check . && ruff format --check . - all checks pass
  • Run mypy . - no type errors

🤖 Generated with Claude Code

Greptile Overview

Greptile Summary

This PR implements automatic coding style guide generation from CLAUDE.md and convention files, injecting the guide into planning and work prompts to ensure consistent coding practices across tasks.

Key Changes:

  • Generates concise (~600 words) coding style guide from CLAUDE.md, linter configs, and convention files
  • Injects style guide into planning and work prompts to enforce project conventions
  • Preserves coding-style.md across runs (not deleted on success) to save tokens on subsequent runs
  • Uses Opus model for high-quality style extraction
  • Comprehensive test coverage with 128+ new tests across multiple test files

Implementation Quality:

  • Clean separation of concerns with new prompts_coding_style.py module
  • Consistent parameter threading through agent.pyagent_phases.py → prompt builders
  • Proper state management with save_coding_style() and load_coding_style() methods
  • Header mismatch issue already fixed in commit e54ced0 (prompt now consistently uses # Coding Style)
  • Documentation updated to reflect new workflow

Test Coverage:

  • Tests validate prompt generation, extraction logic, and edge cases
  • State backup tests confirm coding-style.md preservation during cleanup
  • Planning and working prompt tests verify style guide injection
  • All 4539 tests pass according to PR description

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • Score reflects excellent implementation quality with comprehensive testing (4539 tests passing), proper separation of concerns, consistent patterns, and the header mismatch issue already resolved. The feature is well-documented and follows the project's coding standards from CLAUDE.md (max 500 LOC per file, SRP). No logical errors, security issues, or breaking changes identified.
  • No files require special attention

Important Files Changed

Filename Overview
src/claude_task_master/core/prompts_coding_style.py New file implementing coding style guide generation from CLAUDE.md - well-structured with proper extraction logic
src/claude_task_master/core/agent_phases.py Added generate_coding_style() method and coding_style parameter threading - clean integration
src/claude_task_master/core/planner.py Added ensure_coding_style() to generate/load style guide before planning - good separation of concerns
src/claude_task_master/core/state_backup.py Updated cleanup to preserve coding-style.md for reuse - correctly implements preservation logic
tests/core/test_prompts_coding_style.py Comprehensive tests for prompt generation and extraction - good coverage of edge cases

Sequence Diagram

sequenceDiagram
    participant Orchestrator
    participant Planner
    participant AgentWrapper
    participant AgentPhaseExecutor
    participant StateManager
    participant FileSystem

    Orchestrator->>Planner: create_plan(goal)
    Planner->>Planner: ensure_coding_style()
    Planner->>StateManager: load_coding_style()
    StateManager->>FileSystem: Read coding-style.md
    
    alt coding-style.md exists
        FileSystem-->>StateManager: Return existing style
        StateManager-->>Planner: Return style content
    else coding-style.md missing
        Planner->>AgentWrapper: generate_coding_style()
        AgentWrapper->>AgentPhaseExecutor: generate_coding_style()
        AgentPhaseExecutor->>AgentPhaseExecutor: build_coding_style_prompt()
        AgentPhaseExecutor->>AgentPhaseExecutor: run_query(prompt, planning_tools, Opus)
        AgentPhaseExecutor->>AgentPhaseExecutor: extract_coding_style(result)
        AgentPhaseExecutor-->>AgentWrapper: Return {coding_style, raw_output}
        AgentWrapper-->>Planner: Return style content
        Planner->>StateManager: save_coding_style(content)
        StateManager->>FileSystem: Write coding-style.md
    end
    
    Planner->>StateManager: load_context()
    Planner->>AgentWrapper: run_planning_phase(goal, context, coding_style)
    AgentWrapper->>AgentPhaseExecutor: run_planning_phase(goal, context, coding_style)
    AgentPhaseExecutor->>AgentPhaseExecutor: build_planning_prompt(goal, context, coding_style)
    Note over AgentPhaseExecutor: Injects coding style into prompt
    AgentPhaseExecutor->>AgentPhaseExecutor: run_query(prompt, planning_tools, Opus)
    AgentPhaseExecutor-->>Planner: Return {plan, criteria, raw_output}
    
    Planner->>StateManager: save_plan(plan)
    Planner->>StateManager: save_criteria(criteria)
    
    Note over Orchestrator: Later during work phase
    Orchestrator->>AgentWrapper: run_work_session(task, context, coding_style)
    AgentWrapper->>AgentPhaseExecutor: run_work_session(task, context, coding_style)
    AgentPhaseExecutor->>AgentPhaseExecutor: build_work_prompt(task, context, coding_style)
    Note over AgentPhaseExecutor: Injects coding style into work prompt
    AgentPhaseExecutor->>AgentPhaseExecutor: run_query(prompt, all_tools, model)
    AgentPhaseExecutor-->>Orchestrator: Return {output, success, model_used}
    
    Note over Orchestrator: On success cleanup
    Orchestrator->>StateManager: cleanup_on_success(run_id)
    StateManager->>FileSystem: Delete state files (preserve coding-style.md)
    Note over FileSystem: coding-style.md preserved for reuse
Loading

Context used:

  • Context from dashboard - CLAUDE.md (source)

Add a coding style generation feature that:
- Generates `.claude-task-master/coding-style.md` during planning (if not exists)
- Analyzes CLAUDE.md and convention files to extract:
  - Development workflow (TDD, test-first patterns)
  - Code style conventions (naming, formatting)
  - Project-specific requirements
- Injects the concise guide (~600 words) into:
  - Planning phase prompts (for task creation)
  - Work session prompts (for coding workers)
- Preserves coding-style.md across runs (not deleted on cleanup)
- Uses Opus model for high-quality extraction

Benefits:
- Saves tokens by not repeating verbose instructions in every prompt
- Ensures consistent coding style across all work sessions
- Captures project-specific TDD/workflow patterns from CLAUDE.md

Files changed:
- New: prompts_coding_style.py - Prompt for generating the guide
- New: test_prompts_coding_style.py - Tests for the prompt
- Modified: planner.py - Generate coding style before planning
- Modified: agent_phases.py - Add generate_coding_style method
- Modified: prompts_planning.py/prompts_working.py - Accept coding_style param
- Modified: state_file_ops.py - Add save/load coding style methods
- Modified: state_backup.py - Preserve coding-style.md on cleanup
- Modified: task_runner.py/orchestrator.py - Pass coding style to work sessions
- Updated: CLAUDE.md - Document the new feature

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link

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

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@sebyx07 sebyx07 merged commit 43dcb67 into main Jan 25, 2026
8 of 9 checks passed
@sebyx07 sebyx07 deleted the feat/coding-style-generation branch January 25, 2026 04:23
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