orchestrata_tools.context.prompt_builder

Reference › orchestrata_tools › context › prompt_builder

This module turns a project context into ready-to-send LLM prompts. PromptBuilder wraps a ProjectContextBuilder from project_context. code_review_prompt asks for a review of one module against five points (quality, docstrings and annotations, bugs, test gaps, architecture) and includes module and class counts and the test framework and linter. test_generation_prompt asks for pytest tests for one class, with numbered requirements and the method count. architecture_prompt appends an architecture-review task to the Markdown rendering of the whole context. The prompts are fixed templates with values filled in; the builder makes no LLM call.

At a glance

Source src/orchestrata_tools/context/prompt_builder.py
Lines of code 56
Classes 1
Functions 0
Imports (internal) orchestrata_tools.context.project_context
Imported by orchestrata_tools.context
Tests that import it tests/test_orchestrata_tools.py, tests/test_orchestrata_tools_reviewer_query_indexer.py

Class diagram

Class diagram orchestrata_tools.context.prompt_builder

Dependency diagram

Dependency diagram orchestrata_tools.context.prompt_builder

API

Classes

PromptBuilder

Line 8

Build prompts for LLM code assistance.

Method Signature Summary
__init__ __init__(context_builder: ProjectContextBuilder)
code_review_prompt code_review_prompt(module_path: str) -> str Build a prompt for reviewing a specific module.
test_generation_prompt test_generation_prompt(class_name: str) -> str Build a prompt for generating tests for a class.
architecture_prompt architecture_prompt() -> str Build a prompt for architecture review.

Source

Permalink: https://gitlab.com/MSamy/orchestrata-ultimate-architecture/-/blob/a4cbc2bdf/src/orchestrata_tools/context/prompt_builder.py

"""Build structured LLM prompts from project context."""

from __future__ import annotations

from orchestrata_tools.context.project_context import ProjectContextBuilder


class PromptBuilder:
    """Build prompts for LLM code assistance."""

    def __init__(self, context_builder: ProjectContextBuilder):
        self.ctx = context_builder

    def code_review_prompt(self, module_path: str) -> str:
        """Build a prompt for reviewing a specific module."""
        ctx = self.ctx.build()
        return f"""You are reviewing the Python module `{module_path}` in project `{ctx.name}`.

Project context:
- {ctx.stats.get('modules', 0)} modules, {ctx.stats.get('classes', 0)} classes
- Test framework: {ctx.config.get('test_framework', 'unknown')}
- Linter: {ctx.config.get('linter', 'unknown')}

Please review this module for:
1. Code quality and readability
2. Missing docstrings or type annotations
3. Potential bugs or edge cases
4. Test coverage gaps
5. Architecture concerns

Provide specific, actionable feedback."""

    def test_generation_prompt(self, class_name: str) -> str:
        """Build a prompt for generating tests for a class."""
        ctx = self.ctx.build()
        return f"""Generate comprehensive pytest tests for class `{class_name}` in project `{ctx.name}`.

Project context:
- Test framework: {ctx.config.get('test_framework', 'pytest')}
- {ctx.stats.get('methods', 0)} total methods in codebase

Requirements:
1. Use pytest fixtures where appropriate
2. Test all public methods
3. Include edge cases and error conditions
4. Use descriptive test names: test_<method>_<scenario>
5. Follow existing test conventions in the project

Generate only the test code, no explanations."""

    def architecture_prompt(self) -> str:
        """Build a prompt for architecture review."""
        return (
            self.ctx.to_markdown()
            + "\n\n## Task\n\nReview the overall architecture and suggest improvements for modularity, coupling, and cohesion."
        )