---
name: trestle-init
description: First-time setup of .trestle/ for a project, or refreshing the AGENTS.md pointer block on re-run. Use when the user asks to adopt trestle / start using this workflow in a repo that doesn't have .trestle/ yet.
---

Scaffold `.trestle/`, draft the workspace docs from analysis, grill only
what analysis can't answer, then wire up AGENTS.md.

## Workflow

1. If `.trestle/` already exists: skip to step 6 (refresh AGENTS.md only)
   and report that init already ran.
2. Scaffold from the plugin's `templates/`: copy `workflow.md`, copy
   `checklist-global.md` to `checklist/global.md`, create empty
   `tasks/`, `spec/`, `workspace/`, `temp/` dirs, write `.trestle/.gitignore`
   (`temp/`, `.runtime/`, `.developer`), and write `config.json`:
   `{ "name": <project name>, "verifyCommands": [], "blocker": null }`.
3. Analyze the project before asking anything: directory structure,
   languages, entry points, test/build commands from package manifests,
   recent commit history. Draft `workspace/PRODUCT.md` and
   `workspace/ARCHITECTURE.md` from the templates, filling every section
   you have evidence for and citing the source inline. Anything you
   cannot infer, mark `OPEN: <question>` instead of guessing.
4. Grill only the `OPEN` items — one question at a time, recommendation +
   tradeoff, per `references/interview-rules.md`.
5. Write the final PRODUCT.md / ARCHITECTURE.md (no `OPEN` markers left).
   Ask for a developer name and run `journal.ts init-developer <name>`.
6. Write or refresh the AGENTS.md managed block (create AGENTS.md if it
   doesn't exist) using exactly the block below. Preserve everything
   outside the markers; replace only the content between them.

## AGENTS.md managed block

```
<!-- TRESTLE:START -->
# Trestle Instructions
- .trestle/workflow.md — phases, current-step routing (read first)
- .trestle/workspace/ — PRODUCT.md, ARCHITECTURE.md, journals
- .trestle/tasks/ — active tasks (prd/design/implement/checklist)
- Task CLI: node <plugin>/scripts/task.ts <cmd>
If your platform has trestle commands (/trestle:*), use them.
Otherwise invoke the matching skill: trestle-init, trestle-brainstorm,
trestle-plan, trestle-continue, trestle-handoff, trestle-finish-work.
No hook support? Read workflow.md and follow the phase for the current
task status manually — statuses and next steps are all defined there.
<!-- TRESTLE:END -->
```

## Hard constraints

- Never invent a PRODUCT.md/ARCHITECTURE.md claim without a source; mark
  it `OPEN` and ask instead.
- Never overwrite AGENTS.md content outside the `TRESTLE:START`/`END`
  markers.
- One question per grill round, per interview-rules.

## Output format

```
.trestle/ scaffolded: yes | already existed
PRODUCT.md / ARCHITECTURE.md: written, <n> OPEN items resolved
AGENTS.md: created | block refreshed (outside-block content preserved)
```
