I need to understand what JSON schema the review sub-agents actually need to return, by tracing through the code that parses/imports their output. There are two paths:
The batch review path (holistic batches run by subagents)
The external review path (external Claude sessions)
For each path, trace from where the subagent output JSON is received/parsed through to where it's validated and imported into state. I need to know:
What top-level keys are expected?
What fields are required on each issue/finding?
Is the key called "findings" or "issues"?
What about "dimension_notes", "retrospective", "batch", "batch_index"?
What validation happens on the parsed output?
Start by looking at:
desloppify/app/commands/review/batch/core.py (likely has merge/parse logic)
desloppify/app/commands/review/batch/execution.py (likely has subagent output parsing)
Search for functions that parse subagent JSON output, normalize fields, validate schemas. Look for key names like "findings", "issues", "assessments", "dimension_notes", "retrospective", "batch", "batch_index".
This is a research task — do NOT edit any files. Just report what you find about the actual required schema for each path.
Assistant
I'll trace through the code to understand the JSON schema that review sub-agents need to return. Let me start by exploring the key files you mentioned.
Assistant
Now let me look at the importing contracts and payload normalization:
Assistant
Now let me check the contracts_types file to see the actual TypedDict definitions:
Assistant
Now let me look at the feedback_contract file to understand the dimension_note keys:
Assistant
Now let me look at the external review path (external Claude sessions):
Assistant
Now let me look at how holistic issues are imported from the state:
Assistant
Now let me check the collection/batch results parsing to understand how the subagent output flows:
Assistant
Perfect. Now let me look at where collect_batch_results is called with the actual normalize_result_fn:
Assistant
Let me search for where the batch results are collected in the cmd layer:
Assistant
Let me continue reading and find where collect_batch_results is actually called:
Assistant
Perfect. Now I have a comprehensive view. Let me create one final summary by checking the external Claude session review path. Let me look at the import helpers file to see both paths:
Assistant
Excellent! Now I have all the information I need. Let me compile the comprehensive report:
assessments key is required (line 149: checks isinstance(obj.get("assessments"), dict))
issues key is required (line 150: checks isinstance(obj.get("issues"), list))
Legacy key findings is aliased to issues (function normalize_legacy_findings_alias at core.py:400-405)
Key dimension_notes is optional (core.py:411, defaults to {})
Issue Object Schema (issues Array)
Each issue in the issues array must pass validate_review_issue_payload() from /Users/user_c042661f/Documents/desloppify/desloppify/intelligence/review/importing/contracts_validation.py:
Required Fields (see REVIEW_ISSUE_REQUIRED_FIELDS at line 7-15):
dimension (str, non-empty, must be in allowed_dims)
identifier (str, non-empty)
summary (str, non-empty)
confidence (str, one of: "high", "medium", "low")
suggestion (str, non-empty)
(list[str], at least one file path)
User
I need to understand exactly how the review prompt gets delivered to the sub-agent in the two different review paths: the "batch" path and the "external" path. Specifically:
For the BATCH path (orchestrator.py → execution.py → subagent): How does the prompt get assembled and sent? Does the subagent get the batch_prompt as its task, and then reads the blind packet (which contains system_prompt) from disk? Or does it get both combined?
For the EXTERNAL path (external.py → claude_launch_prompt.md): What exactly goes into the launch prompt? Does it reference the blind packet? Does it include the system_prompt?
Look at:
desloppify/app/commands/review/batch/execution.py - how it launches subagents
desloppify/app/commands/review/batch/orchestrator.py - how it sets up runs
Any runner/launcher code that actually invokes the subagent
I want to know: do both paths deliver the SAME information (system_prompt + dimension_prompts + batch prompt), or are they getting different things?
Research only, do not edit files.
Assistant
I'll trace through both review paths to understand how the prompt gets delivered to the subagent. Let me start by examining the key files.
Assistant
Let me look at the structure and files:
Assistant
Now let me read the batch execution and orchestrator files:
Assistant
Now let me read the external.py file:
Assistant
Now let me look at the key functions that show how the prompt is assembled. Let me check the batch core module to see how the batch prompt is built:
Assistant
Let me find and read the prompt template:
Assistant
Now let me check the runner_packets module to see how prompts are written:
Assistant
Let me read the prepare_run_artifacts function:
Assistant
Now let me check how the subagent is launched with this prompt - look at the runner_process module:
Assistant
Perfect! Now I can see the key difference. Let me look more closely at what's passed in the batch prompt and how it references the blind_packet_path:
Assistant
Now let me check the build_blind_packet function to see what's in the blind packet:
Assistant
Now let me check what's in a full packet to understand what system_prompt and dimension_prompts are and where they live:
Assistant
Let me check the prepare_holistic_flow to understand the packet structure better:
Assistant
Let me continue reading the prepare function:
Assistant
Let me continue to see where the payload is built:
Assistant
Perfect! Now I have all the information I need. Let me create a summary document of my findings. Let me verify what stays in the blind packet versus what gets dropped:
Assistant
Perfect! Now I have all the information. Let me create my comprehensive research report:
Research Findings: Two Review Paths - Prompt Delivery Analysis
I've traced through both the batch and external review paths. Here's exactly how the prompts are delivered in each case:
I need to design a plan to align the two review paths (batch and external) so they both deliver the same context to the reviewer. Here's what I've learned:
For each selected batch, generates a rich prompt via render_batch_prompt() in prompt_template.py
Passes prompt to codex exec — subagent reads blind packet from disk
Each batch output: {batch, batch_index, assessments, dimension_notes, issues, retrospective}
Results merged by merge_batch_results() in merge.py
Merged payload imported via do_import()
External path:
Creates SAME blind packet (same function)
Generates bare-bones 8-line prompt in _build_claude_launch_prompt() in external.py
Writes to markdown file for copy/paste into a Claude session
Single output: {session, assessments, issues} — no dimension_notes, no per-batch structure
CLI wraps with canonical provenance in _canonical_external_payload()
Imported via same do_import()
Key gap: External path doesn't use render_batch_prompt(). Its launch prompt never mentions system_prompt, scoring philosophy, dimension_notes, scoring frame, seed files, etc. The reviewer gets almost no guidance compared to batch subagents.
Design Constraints
Both paths should show the reviewer the same information and use the same scoring rules
The blind packet already contains investigation_batches — same data is available
Batch path runs N parallel codex subagents, one per batch
External path is ONE manual Claude session — the reviewer can't easily produce N separate outputs
The submit flow (do_external_submit) expects a single JSON with session key
The import pipeline already handles both — it just needs assessments and issues
render_batch_prompt generates ONE prompt per batch — it can't directly generate one combined prompt
My Proposed Approach
Rewrite _build_claude_launch_prompt to:
Include session metadata header (token, paths) — keep this
Include the same scoring frame from the batch prompt ("YOUR TASK" / "WHAT WE GIVE YOU AND WHY")
Assistant
I'll start by thoroughly exploring the relevant code to understand the current architecture before evaluating your design.
Assistant
Now let me look at the batch orchestrator to see how it calls render_batch_prompt and the import pipeline.
Assistant
Now let me check the import pipeline to see how it handles dimension_notes and the feedback contract.
Assistant
Now let me check how the batch orchestrator calls render_batch_prompt and how batches are structured in the packet.
Assistant
Let me check how runner_packets prepares artifacts and how the batch prompt is actually built and written.
Assistant
Now let me check how _canonical_external_payload handles dimension_notes and what the batch core module looks like.
Assistant
Good. The import pipeline already handles dimension_notes as an optional field -- if absent it defaults to {}. Now let me check the _canonical_external_payload more carefully -- it strips session and provenance but passes through everything else, so dimension_notes from the reviewer would flow through.
Let me also look at what _build_template_payload currently produces vs what should be in the template.
Assistant
Now I have a thorough understanding of both paths. Let me check one more thing -- the existing tests for the external path.
Assistant
I now have a complete picture. Let me deliver the analysis and plan.
Design Evaluation and Implementation Plan
Your analysis is correct on all key points
Your diagnosis of the gap is accurate: _build_claude_launch_prompt produces 8 bare lines while batch subagents get the full scoring frame, scan evidence guidance, seed files, historical issues, concern signals, dimension-specific focus instructions, and a detailed output schema. The import pipeline already handles dimension_notes as optional (defaults to {}), and _canonical_external_payload passes through all keys except session and provenance, so there is zero submit/import issue with adding dimension_notes to external output.
Option A is the right call, with a specific refinement
You are correct to choose Option A (extract shared rendering functions). However, after reading the code, I would refine the approach: most of the _render_* functions in prompt_template.py are already pure functions that take either a _PromptBatchContext dataclass or a raw batch dict. They do not depend on batch-path-specific infrastructure. The extraction is lighter than it might seem.
Here is what I would specifically extract versus leave in place:
Functions to extract into a new shared module (e.g., desloppify/app/commands/review/prompt_sections.py):
_render_scoring_frame() -- takes no arguments, pure text
_render_scan_evidence_note() -- takes no arguments, pure text
_render_historical_focus(batch) -- takes a raw batch dict
_render_mechanical_concern_signals(batch) -- takes a raw batch dict
_render_scope_enums() -- takes no arguments, pure text
_SCAN_EVIDENCE_FOCUS_BY_DIMENSION dict and _render_scan_evidence_focus(dim_set) -- takes a set
_render_package_org_focus(dim_set), _render_abstraction_focus(dim_set), _render_workflow_integrity_focus(dim_set) -- all take a set
_render_dimension_focus(context) -- takes a _PromptBatchContext; but the external path would call the underlying dim_set functions directly since it does not have per-batch contexts
_coerce_string_list(raw) -- utility
_PromptBatchContext dataclass -- used by both paths to structure batch data
User
Your task is to create a detailed summary of the conversation so far, paying close attention to the user's explicit requests and your previous actions.
This summary should be thorough in capturing technical details, code patterns, and architectural decisions that would be essential for continuing development work without losing context.
Before providing your final summary, wrap your analysis in tags to organize your thoughts and ensure you've covered all necessary points. In your analysis process:
Chronologically analyze each message and section of the conversation. For each section thoroughly identify:
The user's explicit requests and intents
Your approach to addressing the user's requests
Key decisions, technical concepts and code patterns
Specific details like:
file names
full code snippets
function signatures
file edits
Errors that you ran into and how you fixed them
Pay special attention to specific user feedback that you received, especially if the user told you to do something differently.
Double-check for technical accuracy and completeness, addressing each required element thoroughly.
Your summary should include the following sections:
Primary Request and Intent: Capture all of the user's explicit requests and intents in detail
Key Technical Concepts: List all important technical concepts, technologies, and frameworks discussed.
Files and Code Sections: Enumerate specific files and code sections examined, modified, or created. Pay special attention to the most recent messages and include full code snippets where applicable and include a summary of why this file read or edit is important.
Errors and fixes: List all errors that you ran into, and how you fixed them. Pay special attention to specific user feedback that you received, especially if the user told you to do something differently.
Problem Solving: Document problems solved and any ongoing troubleshooting efforts.
All user messages: List ALL user messages that are not tool results. These are critical for understanding the users' feedback and changing intent.
Pending Tasks: Outline any pending tasks that you have explicitly been asked to work on.
Current Work: Describe in detail precisely what was being worked on immediately before this summary request, paying special attention to the most recent messages from both user and assistant. Include file names and code snippets where applicable.
Optional Next Step: List the next step that you will take that is related to the most recent work you were doing. IMPORTANT: ensure that this step is DIRECTLY in line with the user's most recent explicit requests, and the task you were working on immediately before this summary request. If your last task was concluded, then only list next steps if they are explicitly in line with the users request. Do not start on tangential requests or really old requests that were already completed without confirming with the user first.
If there is a next step, include direct quotes from the most recent conversation showing exactly what task you were working on and where you left off. This should be verbatim to ensure there's no drift in task interpretation.
Assistant
User asks to review the "objective review prompt" given to sub-agents to check if it's clear that scores should be based on their own code reading, not automated signals.
I found and read the relevant files:
desloppify/app/commands/review/batch/prompt_template.py - the batch prompt template
desloppify/app/commands/review/external.py - the external review path
desloppify/languages/_framework/review_data/dimensions.json - the system_prompt and dimension definitions
I identified that the anti-anchoring message was scattered across 3 places, buried in dense context, and missing from the system_prompt.
User asked me to think through this from a meta perspective - what we're trying to communicate and how to make it succinct.
I outlined the hierarchy: the frame should be established once, then labeled, not re-argued each time.
User asked to think through the hierarchy of communication - what we need the sub-agents to know.
I outlined 5 levels: job, scope, scoring method, ground rules, and the "what about all this other stuff" meta-instruction.
User asked to think through the scoring philosophy - holistic judgment rather than mathematical subtraction.
I discussed how the current "start at 100, subtract per issue" formula creates perverse incentives, and proposed judgment-based scoring with experiential anchors.
User said "that's good" (in a good direction).
User pointed out that I was being too specific with dimension descriptions - dimensions are different types (consistency, fitness, clarity, craft, risk) and the language should be general enough for all.
I refined the approach to use "how well does this codebase serve a developer from a [dimension] perspective?" as the universal framing.
User asked me to share an updated plan.
I shared a 6-point plan covering: rewrite scoring philosophy, revise anchors, add scoring independence rule, restructure batch prompt, collapse caveats, trim per-dimension anchors.
{
"dimension_coverage": float, # ratio dimensions assessed / total
"evidence_density": float, # evidence count / issues count
"high_score_missing_issue_note": float # count of high-score dims missing issue notes
"high_score_without_risk": float # legacy name (aliased)
}
Validation Rules
Low-score enforcement (core.py:341-360): If any dimension scores below 85.0 (LOW_SCORE_ISSUE_THRESHOLD), that dimension must have at least one explicit issue (feedback_contract.py:5)
High-score note requirement (core.py:437-438): If score > 85.0 (HIGH_SCORE_ISSUES_NOTE_THRESHOLD), dimension must include issues_preventing_higher_score note
Assessment feedback (feedback_contract.py:28-30): Scores below 100.0 must have explicit feedback (issue with suggestion or dimension_notes evidence)
Issue limit: Max issues per batch capped at max(10, dimension_count) (feedback_contract.py:17-20)
PATH 2: EXTERNAL REVIEW (External Claude Sessions)
session.id and session.token (for verification on submit)
Scaffold of assessment structure
Generates launch prompt via _build_claude_launch_prompt() (lines 188-217)
Launch prompt content (lines 188-217):
Returns a markdown string with:
code
# Claude Blind Reviewer Launch Prompt
You are an isolated blind reviewer...
Blind packet: {blind_path}
Template JSON: {template_path}
Output JSON path: {output_path}
Requirements:
1. Read ONLY the blind packet and repository code.
2. Start from the template JSON...
3. Keep `session.id` exactly `{session_id}`...
4. Keep `session.token` exactly `{token}`...
5. Output must be valid JSON with top-level keys: session, assessments, issues.
6. Every issue must include: dimension, identifier, summary, related_files, evidence, suggestion, confidence.
7. Do not include provenance metadata (CLI injects canonical provenance).
8. Return JSON only (no markdown fences).
Saved to: claude_launch_prompt.md (human-readable copy/paste prompt)
What the external reviewer gets:
A markdown file with instructions (the launch prompt)
File paths to:
Blind packet (same structure as batch path)
Template JSON (session structure only)
Expected output path (where to write JSON result)
No embedded system_prompt or dimension_prompts
No batch-specific instruction details (unlike batch path)
Subagent execution (external reviewer, manual):
User/external reviewer copies the launch prompt into a context-isolated Claude conversation
Claude reads the blind packet file
Claude reads the template JSON file
Claude examines the codebase
Claude writes output JSON to the specified path
User submits via desloppify review --external-submit --session-id <id> --import <file>
Key insight for EXTERNAL path:
The external reviewer gets minimal instructions — just the launch prompt (references to files, not content)
The external reviewer must independently read:
The blind packet file (to get system_prompt and dimension_prompts)
The template JSON file (to preserve session metadata)
No batch-specific batching logic — the entire codebase is in scope for a single review session
On submit: CLI reads the output JSON, validates it, wraps it with canonical provenance, and imports it
COMPARISON TABLE
Aspect
BATCH Path
EXTERNAL Path
Prompt delivery
Text passed to codex exec command
Markdown file for copy/paste
System/Dim prompts
Referenced in blind packet file path
Referenced in blind packet file path
Blind packet location
Disk (path in prompt)
Disk (path in launch prompt)
Batch specifics
Full batch instructions embedded in prompt
No batch-specific instructions
Scope
Single batch (seed files + exploration)
Full codebase
Session tracking
Via run summary + batch status
Via session.json with expiry
Subagent context
Codex runner, ephemeral
External Claude conversation
DO BOTH PATHS DELIVER THE SAME INFORMATION?
Not exactly, but structurally yes:
SAME: Both deliver system_prompt and dimension_prompts via the blind packet file (not embedded in task prompt)
SAME: Both scrub score-anchoring metadata from the blind packet
SAME: Both use the same evaluation dimensions and scoring rubric
DIFFERENT: Batch path includes batch-specific seed files, historical issues, and mechanical concern signals in the task prompt itself. External path has none of this — the reviewer must discover issues through code exploration.
DIFFERENT: Batch path batches by dimension/risk (focused investigation). External path reviews everything in one session.
The architecture is consistent: In both cases, the reviewer's task prompt is separate from the dimension/system prompts, and those are always retrieved from the blind packet file at runtime. The difference is in what else is in the task prompt to guide the reviewer's investigation.
review_result.template.json - template for reviewer
claude_launch_prompt.md - blind reviewer prompt
reviewer_instructions.md - instructions
review_result.json - reviewer's output (written by reviewer)
canonical_import_{stamp}.json - canonicalized import file (written by CLI)
Packet directory:.desloppify/review_packets/
review_packet_{stamp}.json - immutable full packet
blind_packet_sha256_{hash}.json - blind packet (no scores/targets)
State:
.desloppify/state-{lang}.json - updated state with issues and assessments
.desloppify/query.json - query output with narrative/scores
Reference the blind packet and tell reviewer to follow system_prompt constraints (same as batch)
Include ALL batch information from the packet: for each batch, list dimensions, seed files, rationale, historical issues, concern signals — essentially a combined view of what batch subagents each get individually
Use the full output schema including dimension_notes (currently missing from external)
Keep the session wrapper requirement (session.id, session.token)
This means _build_claude_launch_prompt would need access to the packet data (to extract batches). Currently it only gets session_id, token, and file paths.
What changes:
_build_claude_launch_prompt signature changes to accept packet dict (or just the batches + blind_path)
The function iterates investigation_batches from the packet and includes their details
Reuses _render_scoring_frame(), _render_scan_evidence_note(), etc. from prompt_template.py — or calls into a shared rendering layer
Output schema includes dimension_notes
Template payload updated to include dimension_notes: {}
What stays the same:
Session creation, token, expiry, provenance — all unchanged
Submit flow (do_external_submit) — works because import pipeline already handles dimension_notes
_canonical_external_payload — unchanged
The import pipeline — unchanged
Blind packet creation — unchanged
Alternative I considered: Make external path generate N separate prompt files and submit N separate outputs. Rejected because it fundamentally changes the external UX from "one session" to "N sessions" which is a bigger refactor and worse for the manual copy/paste workflow.
Question: Should the external prompt reuse render functions from prompt_template.py directly? Or should we extract shared rendering into a common module? prompt_template.py is currently batch-specific (it assumes one batch per prompt). We'd need either:
A) Extract shared functions (scoring frame, scan evidence note, historical focus, concern signals) into a shared module, used by both prompt_template.py and external.py
B) Call render_batch_prompt for each batch and concatenate them into one document with a session header
C) Build the external prompt independently but using the same patterns/text
Option A is cleanest. Option B means the external reviewer sees N output schemas (confusing). Option C duplicates text.
Please evaluate this design, identify any issues, and suggest the cleanest implementation approach. Consider:
What shared rendering functions should be extracted?
What's the right function signature for the new _build_claude_launch_prompt?
Does the template payload need updating?
Are there any issues with the submit/import flow accepting dimension_notes from external?
Functions to leave in prompt_template.py (batch-path-specific composition):
_render_metadata_block() -- batch-specific header with batch_index, packet_path, repo_root
_render_seed_files_block() -- can be extracted but is trivial
_render_task_requirements(context) -- the detailed numbered requirements; this is the most interesting case (see below)
_render_output_schema(context, batch_index) -- output schema differs between paths
render_batch_prompt() -- the batch-path composition function
The task requirements question:_render_task_requirements contains the core scoring contract (rules 1-13). The external prompt needs the same rules, but rule 3 mentions context.issues_cap (per-batch cap). For the combined external prompt, you would want a total cap across all dimensions. I would extract the core requirements text into a shared function that accepts a configurable issues cap, and let each path pass its own value.
Proposed changes, file by file
1. New file: desloppify/app/commands/review/prompt_sections.py
Shared rendering functions extracted from prompt_template.py. Contains:
_PromptBatchContext dataclass (moved)
_coerce_string_list() (moved)
_build_context() (moved, renamed to build_batch_context() since now public)
render_scoring_frame() (moved, made public)
render_scan_evidence_note() (moved, made public)
render_historical_focus(batch) (moved, made public)
render_mechanical_concern_signals(batch) (moved, made public)
render_scope_enums() (moved, made public)
_SCAN_EVIDENCE_FOCUS_BY_DIMENSION and render_scan_evidence_focus(dim_set) (moved)
render_dimension_focus(context_or_dim_set) -- overloaded to accept either a _PromptBatchContext or a raw set[str]
render_task_requirements(*, issues_cap: int, dim_set: set[str]) -- extracted core of _render_task_requirements, parameterized on issues_cap
render_seed_files_block(context) (moved)
render_output_schema(*, batch_name: str | None, batch_index: int | None, dimensions: tuple[str, ...], include_batch_keys: bool, include_session_keys: bool) -- parameterized to produce either the batch schema or the external session schema
Becomes a thin wrapper: imports from prompt_sections and composes render_batch_prompt() using those building blocks. The batch-specific _render_metadata_block stays here. The function signatures and public API (render_batch_prompt) remain identical.
The packet argument is the already-available packet dict (passed from do_external_start, which already has it in scope at line 233). No new data loading needed.
The function body changes to:
Session header (session_id, token, blind_path, template_path, output_path) -- same as now
render_scoring_frame() from prompt_sections
render_scan_evidence_note() from prompt_sections
For each batch in packet["investigation_batches"]:
render_dimension_focus(dim_set) for that batch's dimensions
Combined task requirements via render_task_requirements(issues_cap=total_cap, dim_set=all_dims) where total_cap is sum of per-batch caps or a reasonable combined max
render_scope_enums() from prompt_sections
External output schema (with session wrapper, dimension_notes, no batch/batch_index keys)
4. Modified: _build_template_payload in external.py
Add dimension_notes to the template:
python
def _build_template_payload(packet: dict[str, Any], *, session_id: str, token: str) -> dict[str, Any]:
dimensions = [
dim for dim in packet.get("dimensions", [])
if isinstance(dim, str) and dim.strip()
]
return {
"session": {"id": session_id, "token": token},
"assessments": {dim: 0 for dim in dimensions},
"dimension_notes": {},
"issues": [],
}
5. No changes to _canonical_external_payload -- already passes through all non-session/non-provenance keys including dimension_notes.
6. No changes to the import pipeline -- dimension_notes is already handled as an optional dict.
Answering your specific questions
Should the external prompt reuse render functions from prompt_template.py directly?
No. Extract the shared parts into prompt_sections.py. This keeps prompt_template.py as a batch-specific composition layer and gives external.py access to the same building blocks without importing batch-specific code.
What shared rendering functions should be extracted?
All the pure rendering functions listed above. The key insight is that every _render_* function in prompt_template.py except _render_metadata_block is already context-agnostic -- they take either nothing, a dim_set, or a batch dict. They are batch-agnostic building blocks that happen to live in a batch-specific file.
What is the right function signature for the new _build_claude_launch_prompt?
Add packet: dict[str, Any] as a keyword argument. The packet is already in scope at the call site (line 277 of external.py, inside do_external_start). No other signature changes needed. The function internally iterates packet.get("investigation_batches", []) to render per-batch sections.
Does the template payload need updating?
Yes. Add "dimension_notes": {} to _build_template_payload output. This signals to the reviewer that dimension_notes are expected and gives them the structure to fill in.
Are there any issues with the submit/import flow accepting dimension_notes from external?
No. The import pipeline at importing/parse.py:101 already calls _coerce_optional_object(payload, key="dimension_notes", errors=errors) which accepts it as an optional dict defaulting to {}. The _canonical_external_payload function passes through all keys except session and provenance. The feedback validation at parse.py:255-256 already uses _feedback_dimensions_from_dimension_notes to credit dimension_notes evidence toward feedback requirements. Everything works end-to-end today if the external reviewer includes dimension_notes.
Implementation sequence
Create prompt_sections.py with extracted functions
Update prompt_template.py to import from prompt_sections (keep render_batch_prompt API identical)
Run tests to verify batch path is unchanged
Update _build_template_payload to include dimension_notes: {}
Rewrite _build_claude_launch_prompt to accept packet and use shared rendering
Update the call site in do_external_start (line 277) to pass packet=packet
Update test test_external_start_creates_session_and_template to verify the new prompt content (scoring frame present, batch info present, dimension_notes in template)
Add a focused test for _build_claude_launch_prompt that verifies it includes scoring frame, batch details, seed files, and the full output schema
Potential challenges
Prompt length for external sessions: If there are many batches (the batch path typically runs 3-5), the combined prompt could be long. This is fine for copy/paste into Claude but worth keeping in mind. The prompt will be roughly N times the per-batch content plus shared sections.
Issues cap calculation for external: Each batch has its own issues_cap based on max_batch_issues_for_dimension_count(len(dims)). For the combined prompt, use the sum across all batches, or just max_batch_issues_for_dimension_count(total_dimension_count). The latter is cleaner since the external reviewer produces a single combined output.
Output schema difference: The batch schema has batch and batch_index keys. The external schema has session.id and session.token. The shared render_output_schema needs to be parameterized for this. Alternatively, write the external output schema separately since it is different enough.
Critical Files for Implementation
/Users/user_c042661f/Documents/desloppify/desloppify/app/commands/review/batch/prompt_template.py - Source of all rendering functions to extract
/Users/user_c042661f/Documents/desloppify/desloppify/app/commands/review/external.py - Primary file to modify: _build_claude_launch_prompt and _build_template_payload
/Users/user_c042661f/Documents/desloppify/desloppify/app/commands/review/importing/parse.py - Confirms dimension_notes already handled in import pipeline (no changes needed)
/Users/user_c042661f/Documents/desloppify/desloppify/intelligence/review/feedback_contract.py - Shared constants used by both rendering and validation
/Users/user_c042661f/Documents/desloppify/desloppify/tests/review/import_scoring/test_review_external.py - Existing test to update for new prompt content and template shape
Here's an example of how your output should be structured:
Key Technical Concepts:
[Concept 1]
[Concept 2]
[...]
Files and Code Sections:
[File Name 1]
[Summary of why this file is important]
[Summary of the changes made to this file, if any]
[Important Code Snippet]
[File Name 2]
[Important Code Snippet]
[...]
Errors and fixes:
[Detailed description of error 1]:
[How you fixed the error]
[User feedback on the error if any]
[...]
Problem Solving:
[Description of solved problems and ongoing troubleshooting]
All user messages:
[Detailed non tool use user message]
[...]
Pending Tasks:
[Task 1]
[Task 2]
[...]
Current Work:
[Precise description of current work]
Optional Next Step:
[Optional Next step to take]
Please provide your summary based on the conversation so far, following this structure and ensuring precision and thoroughness in your response.
There may be additional summarization instructions provided in the included context. If so, remember to follow these instructions when creating the above summary. Examples of instructions include:
Compact Instructions
When summarizing the conversation focus on typescript code changes and also remember the mistakes you made and how you fixed them.
IMPORTANT: Do NOT use any tools. You MUST respond with ONLY the ... block as your text output.
prompt_template.py - added _render_scoring_frame(), collapsed inline caveats to brief labels, simplified task requirement 1b, updated render order
feedback_contract.py - checked, no changes needed
Tests passed (4258 passed)
User asked to see the full example with both prompts and whether the response format is clear.
I rendered the full example showing batch prompt + system_prompt + dimension prompts, and identified the schema mismatch: system_prompt said findings while batch prompt said issues, and the schemas differed.
User asked me to reconcile the schemas by looking at both paths.
Both use same validate_review_issue_payload() with required fields: dimension, identifier, summary, confidence, suggestion, related_files, evidence
I reconciled: changed all findings → issues in system_prompt, added dimension_notes to system_prompt schema, updated NON-FINDINGS → NON-ISSUES, updated IMPORT GUARD. Fixed test that checked for "IMPORT GUARD" string.
User said it seems like a LOT and asked how to make it more succinct.
I proposed strategic cuts - the biggest being removing per-dimension anchors (1,600 words, half the prompt). Also collapsing rules 7-10 into one, removing rules 11-12 (redundant with new philosophy), removing output schema from system_prompt (batch prompt has it), removing IMPORT GUARD from system_prompt.
User said "just think this through strategically" - wanted me to reason not implement.
I confirmed no valuable information would be lost with the cuts, and explained why two prompts exist (system_prompt = job description in blind packet, batch prompt = specific assignment).
User asked me to implement the cuts and show the updated prompt, and explain why two prompts.
I implemented: system_prompt went from ~3,200 words to ~650 words. Rules went from 13 to 7. Removed per-dimension anchors entirely. Removed output schema (now says "Return JSON matching the schema in your task instructions"). Tests passed.
User asked to see a full example of the overall thing and whether it's clear how to submit issues.
I rendered the full example. User couldn't see it initially.
User asked me to look at the two different ways sub-agents receive prompts and make sure they're consistent. Pointed out they should be seeing the same context.
I traced both paths:
Batch: gets rich render_batch_prompt + reads blind packet from disk
External: gets 8-line _build_claude_launch_prompt + reads blind packet from disk
External never mentions system_prompt, no scoring frame, different output schema, no seed files, no dimension_notes
User asked to make a plan for Option A (make external batch-aware) and think through how both paths work.
I entered plan mode. Launched explore agents for both paths. Launched a plan agent.
I wrote the plan to the plan file. The plan:
Extract shared rendering functions into prompt_sections.py
Both paths compose from same building blocks
External prompt gets rewritten to use same scoring frame, seed files, historical issues, etc.
Template payload updated with dimension_notes
No changes to import pipeline, submit flow, or blind packet creation
User's most recent messages emphasize: "extremely confident that existing approaches will continue to work", "both fed the same context", "maybe feeding it in a different way with the same context", "both instructed to read it."
Now let me document the actual code changes made so far:
Updated _render_historical_focus() - added "navigation aid, not scoring evidence" label
Simplified task requirement 1b from 5 lines to 2
Updated render order to put scoring frame after metadata
Changed "NOT findings" → "NOT confirmed issues"
Test fix:
test_holistic_review.py line 137: changed assert "IMPORT GUARD" in REVIEW_SYSTEM_PROMPT to assert "SCORING PHILOSOPHY" in REVIEW_SYSTEM_PROMPT
The plan file was written to /Users/user_c042661f/.claude/plans/resilient-shimmying-scroll.md.
The user's most recent message before the summary request emphasized wanting confidence that both existing approaches will continue to work and both see the same context.
Key Technical Concepts:
Two review paths: batch path (codex exec subagents, parallel, per-batch) and external path (manual Claude session, single-session, all dimensions)
Blind packet: JSON file containing system_prompt, dimension_prompts, holistic_context, investigation_batches — shared by both paths, scrubbed of score-anchoring data
Judgment-based scoring: Scores reflect holistic developer experience, not a formula. Issues illustrate judgment, not inputs to calculation.
Scoring independence: Automated signals are navigation aids, not evidence or inputs to scores
Two-part frame: "YOUR TASK" (what to do) + "WHAT WE GIVE YOU AND WHY" (automated signals are navigation aids)
Navigation aid labeling: Each automated data section gets a brief "navigation aid, not scoring evidence" label instead of per-section caveats
Dimension prompt as rubric: Each dimension's look_for/skip list defines what good looks like for that specific quality
Contains the system_prompt field (the foundational instruction set shared across all review modes) and dimension_prompts (per-dimension rubrics)
Major rewrite of system_prompt: added SCORING PHILOSOPHY + SCORING INDEPENDENCE sections, consolidated rules from 13 to 7, removed per-dimension anchors (~1,600 words), removed output schema (references task instructions instead), rewrote global anchors as developer experience descriptions, changed all "findings" → "issues"
Current system_prompt (trimmed version, ~650 words):
code
"system_prompt": "You are a code quality reviewer. Evaluate the provided codebase for subjective quality issues that linters cannot catch. Navigate the codebase as you see fit — follow the evidence where it leads.\n\nSCORING PHILOSOPHY:\nYour score for each dimension is a holistic judgment: how well does this codebase serve a developer from a [dimension] perspective? The dimension prompt defines what good looks like — that is your rubric. Read the code, form an impression, and place it on the scale. Issues are illustrations that support your judgment — they explain WHY you scored as you did, not inputs to a formula...\n\nSCORING INDEPENDENCE:\nIf automated signals, scan evidence, or historical issues are provided alongside the code, treat them as navigation aids — starting points for where to look. They are NOT evidence and NOT inputs to your judgment...\n\nRULES:\n1. Only emit issues you are confident about...\n2. Every issue MUST include related_files, evidence, and a concrete actionable suggestion.\n3. Be specific...\n4. Calibrate confidence...\n5. Treat comments/docstrings as CODE to evaluate...\n6. ISSUES MUST BE DEFECTS ONLY...\n7. Quick fixes vs planning...\n\n...SCORE ANCHORS — what each range means for the developer experience:\n- 100: exemplary. This quality is reliably strong with no material issues.\n- 90: strong. A developer would trust what they see, with only minor friction.\n- 80: solid but uneven. Recurring friction — moments of \"why is this different?\"\n...\n\nOUTPUT: Return JSON matching the schema in your task instructions. The task prompt specifies the exact output format."
Generates per-batch task prompts for codex subagents
Added _render_scoring_frame() function after _render_metadata_block:
python
def _render_scoring_frame() -> str:
return (
"YOUR TASK: Read the code for this batch's dimensions. For each dimension, judge "
"how well the codebase serves a developer from that perspective. The dimension "
"prompt in the blind packet defines what good looks like — that is your rubric. "
"Cite specific observations that explain your judgment.\n\n"
"WHAT WE GIVE YOU AND WHY: Below you will find automated scan evidence, historical "
"issues, and mechanical concern signals. These are navigation aids — starting points "
"for where to look. They are NOT evidence, NOT confirmed issues, and NOT inputs to "
"your scores. Only what you observe directly in the code informs your judgment.\n\n"
)
lines.append("Mechanical concern signals — navigation aid, not scoring evidence:")
lines.append(
"Confirm or refute each with your own code reading. Report only confirmed defects."
)
Updated _render_historical_focus() header to "Previously flagged issues — navigation aid, not scoring evidence:"
Simplified task requirement 1b from 5 lines to 2 lines
Updated render order in render_batch_prompt() to include _render_scoring_frame() after metadata
desloppify/app/commands/review/external.py
Contains _build_claude_launch_prompt() — the bare-bones 8-line external prompt that needs rewriting
Fixed test that checked for "IMPORT GUARD" string (removed from system_prompt):
python
# Changed from:
assert "IMPORT GUARD" in REVIEW_SYSTEM_PROMPT
# To:
assert "SCORING PHILOSOPHY" in REVIEW_SYSTEM_PROMPT
desloppify/app/commands/review/runner_process.py
Contains codex_batch_command() and run_codex_batch() — how batch subagents are launched
Prompt passed as command-line arg to codex exec
Errors and fixes:
Test failure after removing IMPORT GUARD from system_prompt: test_system_prompt_exists in test_holistic_review.py asserted "IMPORT GUARD" in REVIEW_SYSTEM_PROMPT. Fixed by changing assertion to check for "SCORING PHILOSOPHY" instead.
User feedback on being too dimension-specific: I initially wrote anchor descriptions using dimension-specific language (e.g., "patterns"). User pointed out dimensions cover different qualities (consistency, fitness, clarity, craft, risk) — the universal framing should be "how well does this codebase serve a developer from a [dimension] perspective?"
User feedback on verbosity: After seeing the full prompt, user said "That seems like a LOT." Led to the strategic cuts that removed ~2,000 words (per-dimension anchors, redundant rules, duplicate schema).
User feedback on being too hasty: User said "just think this through strategically, please" when I started implementing instead of reasoning first.
Problem Solving:
Anti-anchoring scattered across 3 places: Solved by establishing the frame once up front ("YOUR TASK" / "WHAT WE GIVE YOU AND WHY") and using brief consistent labels ("navigation aid, not scoring evidence") on each data section
Mechanical scoring formula: Replaced "start at 100, subtract per issue" with judgment-based approach. Score = holistic impression, issues = illustrations
Schema mismatch (findings vs issues): System_prompt said findings, batch code expected issues. Reconciled to issues everywhere with findings as legacy alias in parser
Output schema duplication: System_prompt and batch prompt had competing schemas. Removed schema from system_prompt, made batch prompt the single source
Two paths delivering different context: Identified that external path's launch prompt is fundamentally disconnected from the batch path's rich prompts. Plan created to align them.
All user messages:
"Can you look at this objective review prompt that we give to the sub-agents and try to understand, do we stress enough that their score that they give should be based on their actual read of the code issues and not on any of the automated stuff that we share with them? Is that abundantly clear to them?"
"And just think through from a meta perspective like what we're trying to communicate in this whole thing and how we can make it as succinct as possible without losing any of the context that we have. Yeah so can you just think that through please"
"And think through the philosophy. Let's just think through the philosophy of how to actually approach a score... I want this to be kind of a holistic score that represents just how well the code base is doing on that metric and for us to be clear have a clear like definition of what amazing looks like so it should be less of like a mathematical exercise and more of like a judgment if that makes sense"
"Yeah, that's good. Thank you. As in, it's in a good direction."
"But just consider for a second that like you're kind of like using very specific language, but in this they're looking at different dimensions... So just think about what the general message should be, what the subjective message for each specific kind of a thing that they're looking at should be and so on."
"And please share like an updated plan based on this kind of idea."
"So it should be more directed towards them like your like for example like your school or flex how well this this code services developer from a then it's like dimension name perspective... can you just basically Implement this please and then once you've implemented it just share the overall thing with me with an example from a specific or a specific dimension so I can see what it actually looks like in practice"
"Can you share a full example of what the overall thing looks like? And are they, is it clear how they submit issues and what format the actual response should be in?"
"Yes please just figure out what actually is required from our system I think there's two paths for submitting tasks you know there's one for when it's a sub agent that we apply and there's another one for the batch review agents but can you just look through them both and figure out which is the actual proper one and then just reconcile this..."
"THat seems like a LOT - how could we make it more succint while maintaining relevant context?"
"Will we lose out on anything valuable there? If not can you try and do it and then show me the updated prompt please and explain to me just at a high level why do we have two prompts"
"Just think this through strategically, please."
"So, do both the subagents and the actual BatchPram things, so that both of them actually just read the same batch path thing. Can you just understand that, if they like, just understand the two paths and just understand if they actually both see the same thing, cause I'm not sure if they actually do."
Pending Tasks:
Implement the plan to align external and batch review paths — Plan written to /Users/user_c042661f/.claude/plans/resilient-shimmying-scroll.md, awaiting user approval via ExitPlanMode
Simplifying prompt_template.py to import from shared module
Rewriting _build_claude_launch_prompt in external.py to use shared rendering
Updating _build_template_payload to include dimension_notes: {}
Updating call site in do_external_start
Current Work:
I was in plan mode designing the alignment of the external and batch review paths. I had:
Launched explore agents to trace both the batch execution flow and external review flow in detail
Launched a plan agent to design the implementation approach
Written the plan to /Users/user_c042661f/.claude/plans/resilient-shimmying-scroll.md
Was about to call ExitPlanMode for user approval when the user sent a follow-up message emphasizing confidence that both paths will continue to work
The user's most recent substantive message was: "You should be extremely confident that the existing both approaches that we use existing will actually continue to work and that they both fed the same context in the same and maybe feeding it in a different way with the same context and they're both instructed to read it."
This reinforces the plan's approach: extract shared rendering into prompt_sections.py, both paths compose from the same building blocks, delivery mechanism differs (codex exec vs markdown file), but content is identical.
Optional Next Step:
Call ExitPlanMode to present the plan for user approval, then implement the plan from /Users/user_c042661f/.claude/plans/resilient-shimmying-scroll.md. The user explicitly asked: "can you make a plan to do option a" and the plan is written but not yet approved. The user's final emphasis was on confidence that both existing approaches continue working — this should be verified during implementation via comprehensive testing.
"Yeah just actually just please just think through the system like my understanding is that they're like the same thing but they're communicated the information in a different way. So I think we should basically you should just try to make it aligns to make it perfectly, like, exactly the same thing that they're both seeing the same context, you know, but they're seeing it through different paths... So you just think about how to merge this please."
"And can you make a plan to do option a and just think through um um just think through how both paths actually work and just make sure that how we do it actually makes sense for both them considering how they actually work..."
"You should be extremely confident that the existing both approaches that we use existing will actually continue to work and that they both fed the same context in the same and maybe feeding it in a different way with the same context and they're both instructed to read it."