Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions .agents/references/map-json-output-contracts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# MAP JSON Output Contracts

Use these contracts when a MAP skill prompt asks an agent to return JSON that is not already covered by evidence-first output examples.

Every `Output JSON with:` prompt section must be either:

- Evidence-first: include `evidence` or `quotes` before verdict, risk, score, root-cause, or decomposition judgment fields, and link to `map-output-examples.md` when the prompt is high-risk.
- Reference-backed: cite one of the compact workflow contracts below before listing fields.

## Decomposition Output

Use for TaskDecomposer prompts that split a user request into ordered work units.

Required shape:

```json
{
"subtasks": [
{
"id": "string",
"description": "string",
"acceptance_criteria": "string | array",
"depends_on": []
}
],
"total_subtasks": 1
}
```

The prompt may add workflow-specific fields such as `debug_type`, `estimated_complexity`, or `estimated_duration`, but it must keep subtasks atomic, testable, and dependency-aware.

## Actor Change Summary

Use for Actor prompts that edit files directly and return a compact status summary instead of serialized file contents.

Required shape:

```json
{
"approach": "string",
"files_changed": ["path/to/file"],
"tests_run": [],
"remaining_risks": []
}
```

The prompt may add workflow-specific fields such as `trade_offs`, `why_this_fixes_it`, or `potential_side_effects`. `tests_run` is an array of command strings and should be empty when no tests were run. The prompt must still say that files were edited directly with Edit/Write tools and that full file contents must not be serialized in the response.

## Monitor Verdict

Use for Monitor prompts that validate written repository state.

Required shape:

```json
{
"valid": true,
"issues": [],
"verdict": "approved | needs_revision | rejected",
"feedback": "string"
}
```

If the Monitor prompt can reject, block, or materially change workflow direction based on code, test output, or artifacts, prefer the evidence-first review finding contract from `map-output-examples.md` and include evidence before verdict fields.

## Learning Summary

Use for Reflector or learning prompts that extract durable rules from a completed workflow.

Required shape:

```json
{
"key_insight": "string",
"patterns_used": [],
"patterns_discovered": [],
"suggested_new_bullets": [],
"workflow_efficiency": {}
}
```

The prompt must also tell the agent not to repeat existing learned rules already shown in context.

75 changes: 75 additions & 0 deletions .agents/references/map-output-examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Evidence-First Output Examples

Use these compact examples when a MAP prompt asks an agent to return JSON after reviewing code, specs, logs, or workflow artifacts.

## Review Finding

```json
{
"evidence": [
{
"file_path": "src/service.py",
"line_range": "42-47",
"quote": "user_id = request.args['user_id']",
"relevance": "The value is trusted before authorization checks."
}
],
"valid": false,
"verdict": "needs_revision",
"issues": [
{
"severity": "HIGH",
"category": "security",
"description": "The endpoint trusts a caller-controlled user id before authz.",
"file_path": "src/service.py",
"line_range": "42-47",
"suggestion": "Resolve the authenticated principal first and compare it to the requested account."
}
]
}
```

## Debug Root Cause

```json
{
"quotes": [
{
"source": "test output",
"locator": "pytest tests/test_service.py::test_retry",
"quote": "AssertionError: expected 3 attempts, got 1",
"relevance": "Confirms the retry loop exits after the first failure."
},
{
"source": "src/retry.py",
"locator": "lines 18-23",
"quote": "except TimeoutError: raise",
"relevance": "The handler re-raises instead of continuing the retry loop."
}
],
"root_cause": "TimeoutError is re-raised before the retry counter can advance.",
"next_steps": ["Change the TimeoutError branch to continue until attempts are exhausted."]
}
```

## Spec Review Finding

```json
{
"evidence": [
{
"file_path": ".map/feature/spec_feature.md",
"line_range": "31-39",
"quote": "Background sync runs every 5 minutes",
"relevance": "The spec omits conflict handling for overlapping sync runs."
}
],
"finding": {
"severity": "HIGH",
"category": "concurrency",
"description": "The spec schedules repeated background work but does not define locking or idempotency.",
"suggested_fix": "Add an invariant for single active sync per account and define stale-lock recovery."
}
}
```

65 changes: 65 additions & 0 deletions .agents/references/map-xml-prompt-envelopes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# MAP XML Prompt Envelopes

Use this reference when a MAP skill builds a long subagent prompt that mixes user
requirements, persisted artifacts, workflow policy, and an output contract.

## Purpose

MAP prompts should preserve the user's requirements and branch artifacts before
asking an agent to reason over them. For long-context prompts, put the documents
or artifacts first, then the task and instructions, then the expected output.

This follows Anthropic's prompt engineering guidance, accessed 2026-05-19:

- `https://docs.anthropic.com/en/docs/build-with-claude/prompt-engineering/use-xml-tags`
- `https://docs.anthropic.com/en/docs/build-with-claude/prompt-engineering/long-context-tips`

The relevant constraints are:

- use consistent, descriptive XML tags when prompts mix instructions, context,
examples, and variable inputs
- put long documents and data above the query/instructions for long-context work
- wrap multi-document inputs in nested document tags with source metadata
- keep output contracts in their own section so schema requirements are not
confused with task context

## Standard Envelope

```xml
<documents>
<document source="path-or-origin">
<document_content>
...long artifact, diff, spec, finding, or request...
</document_content>
</document>
</documents>

<task>
The one-sentence job for this agent.
</task>

<workflow_policy>
The MAP phase rules, ordering constraints, and hard stops that apply to this
agent call.
</workflow_policy>

<instructions>
The concrete checks or actions the agent should perform, in order.
</instructions>

<expected_output>
The response schema, evidence requirements, and any formatting constraints.
</expected_output>
```

## Rules

- Keep artifact text inside `<documents>` or `<artifacts>` before instructions.
- Use `<task>` for the user's goal or current subtask, not markdown `**Task:**`
inside generated subagent prompts.
- Use `<workflow_policy>` for MAP sequencing rules and hard stops.
- Use `<constraints>` when the agent must obey scope, file, or phase limits.
- Use `<expected_output>` for JSON fields and evidence-first requirements.
- Keep existing MAP semantic tags such as `<MAP_Contract>` and `<map_context>`;
they may live inside `<documents>` or `<artifacts>` when they are input data.

Loading