/contree:setup-mental-modelfrom contree
Discovers domain knowledge from a project's code, tests, and docs, reconciling into a structured seven-section mental model. Creates a template for new projects and installs steering hooks for ongoing alignment.
Ships in contree. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Establish the project's domain theory with the operator and make coding agents load and reconcile it on every turn. Evidence owns the content; the fixed seven-section form owns its shape.
Inspect the project root, manifests, source, tests, public documentation, configuration, history available in the workspace, and any existing MENTAL_MODEL.md.
An existing project has consumer-visible behaviour or domain decisions evidenced by its files. A new project has neither, even when manifests or empty source directories exist.
Explain that discovery will gather supported domain knowledge from running code, tests, public seams, documentation, configuration, and recorded decisions. Propose complete non-overlapping areas that cover the project exactly once. Agree the evidence and non-overlapping discovery areas with the operator before dispatching work.
Discovery subagents inspect every agreed area. Dispatch at least one subagent even for a small existing project. Give each subagent exclusive file or capability ownership and require file paths plus the directly observed evidence for every claim.
Every report covers domain identity, world-to-code mapping, language, boundaries, invariants, rationale, temporal knowledge, and contradictions from inspected files:
Discovery is read-only. Subagents do not edit the mental model or resolve contradictions.
Reconcile the evidence with the operator. Deduplicate overlapping findings, prefer direct behaviour and recorded decisions over inference, and use the project's established vocabulary.
Write MENTAL_MODEL.md with exactly these seven H2 sections in this order:
## Core Domain Identity## World-to-Code Mapping## Ubiquitous Language## Bounded Contexts## Invariants## Decision Rationale## Temporal ViewMove supported existing content into its owning section. Remove no supported knowledge merely to shorten the file. Do not create extra H2 sections, metadata sections, appendices, or parallel mental-model documents.
Keep unsupported claims and consequential disagreements visible in the reconciliation presented to the operator. Do not invent evidence or silently resolve them. Put only agreed, evidenced statements into MENTAL_MODEL.md; report unresolved claims and disagreements separately with their conflicting evidence.
Obtain operator agreement on the reconciled seven-section mental model before installing steering.
Create the seven-section mental-model home in MENTAL_MODEL.md with the same seven H2 headings in the exact order above. Put one concise line under each heading describing the evidence that belongs there, without inventing domain knowledge. Do not infer a product identity, vocabulary, boundary, invariant, rationale, or lifecycle from empty scaffolding.
Install and prove the same project-local steering hooks used by an existing project.
Create executable .contree/hooks/load-mental-model.sh:
#!/usr/bin/env bash
set -euo pipefail
root=$(git rev-parse --show-toplevel)
model="$root/MENTAL_MODEL.md"
if [ ! -f "$model" ]; then
printf '%s\n' 'MENTAL_MODEL.md is missing at the project root' >&2
exit 2
fi
printf '%s\n\n' '# Mental Model'
cat "$model"
printf '%s\n' 'Use the mental model vocabulary and preserve its invariants. Surface consequential conflicts instead of routing around them.'
The project-local SessionStart hooks load the complete MENTAL_MODEL.md before coding agents work. They emit the model and steering on stdout and fail visibly if the repository root or model cannot be read.
Create executable .contree/hooks/reconcile-mental-model.sh:
#!/usr/bin/env bash
set -euo pipefail
input=$(cat)
if printf '%s' "$input" | jq -e '.stop_hook_active == true' >/dev/null 2>&1; then
printf '{}\n'
exit 0
fi
root=$(git rev-parse --show-toplevel)
model="$root/MENTAL_MODEL.md"
if [ ! -f "$model" ]; then
printf '%s\n' 'MENTAL_MODEL.md is missing at the project root' >&2
exit 2
fi
printf '%s\n' 'MENTAL MODEL: Reconcile newly learned domain knowledge before finishing. Identify its owning section, prefer tightening existing knowledge, preserve evidenced invariants, and keep consequential conflicts visible. If this turn learned nothing new, reply 0.' >&2
exit 2
The project-local Stop hooks ask the coding agent to reconcile newly learned domain knowledge before it finishes. The stop_hook_active guard prevents the hook's follow-up turn from creating a loop.
Merge synchronous command entries into both .claude/settings.json and .codex/hooks.json without replacing project-owned settings or existing hooks:
{
"hooks": {
"SessionStart": [
{
"hooks": [
{
"type": "command",
"command": "bash \"$(git rev-parse --show-toplevel)/.contree/hooks/load-mental-model.sh\"",
"statusMessage": "Loading mental model"
}
]
}
],
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "bash \"$(git rev-parse --show-toplevel)/.contree/hooks/reconcile-mental-model.sh\"",
"statusMessage": "Reconciling mental model"
}
]
}
]
}
}
Use the exact project configuration schema supported by the installed harness version while preserving these event and command semantics. Merge into existing event arrays rather than duplicating an identical command.
Preserve complete output from both scripts. Do not capture, summarize, truncate, redirect away, or swallow model content and errors. Fail visibly with the complete native error and exit 2 when either hook cannot find the project root, read the mental model, parse its required input, or execute its dependency.
Require both harnesses to load and trust the project configuration.
Prove both hooks through actual coding-agent turns before reporting completion. A script invocation is not proof that a harness loaded, trusted, and delivered a project hook.
For both Claude Code and Codex:
Repair the script, configuration merge, trust, permissions, or event delivery whenever proof fails, then repeat the actual turn. Do not report completion until SessionStart and Stop delivery are proven under both harnesses.
Report the agreed discovery areas, evidence sources, reconciled or empty mental-model result, unresolved claims, installed hook paths, project configurations, and four actual-turn proof results to the operator.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub elimydlarz/claude-code-plugins --plugin contree15 skills in this plugin
/bootstrap-test-treesCompose mental-model and test-tree setup, then implement every existing-project tree through a second subagent wave. TRIGGER when: the operator asks to bootstrap, backfill, discover, or implement a project's existing behaviour as test trees and tests./changeSet expected behaviour by writing or modifying test trees before code changes. TRIGGER when: the user describes a feature, capability, behaviour change, removal, or modification they want — even loosely (e.g. 'I want X', 'let's add Y', 'can we make it do Z', 'change how X works', 'remove this behaviour')./change-without-meRun the complete Contree arc from idea to independently reviewed working software without routine operator phase transitions: change sets the contract, sync audits it, tdd closes every gap, mutation and completion sync prove the result, and second-opinion findings are repaired before completion. TRIGGER when: the user wants the full workflow, asks to take an idea through implementation, asks to make the project complete, or wants change/sync/tdd handled end to end./diff-for-humansGenerate a single image that explains the current change to a human, using OpenAI's gpt-image-2 model — foregrounding the technical substance the change touches (contracts, databases, behaviour, test trees). TRIGGER when: the user runs /diff-for-humans, or asks to see, picture, illustrate, or visualise the current change or diff./fix-architectureRepair every reported architecture violation with partitioned subagent work and rerun boundary feedback until green. TRIGGER when: architecture lint reports violations or an operator asks to fix dependency direction, purity, composition-root, or cycle problems./second-opinionGet an independent review of completed work from OpenAI's gpt-5.6-sol with high reasoning effort — sends the work and test-tree contract through the Responses API with OPENAI_API_KEY and surfaces its critique. TRIGGER when: sync has just finished, the user asks for a second opinion, an independent review, or a sanity check on completed work before a PR or release.