---
{
  "n": 42,
  "title": "Templates - instructions put in front of any resource",
  "abstract": "What a template is, how it is applied to any resource, how the agent is told, and the plan templates that come first",
  "refs": [],
  "seen": [
    "agent",
    "user"
  ],
  "data": {
    "revisions": 1,
    "open_until": 0,
    "kept": false
  },
  "created": 1790028266.891237,
  "updated": 1790093387.593782,
  "deleted": 0.0,
  "completed": 0.0,
  "outcome": "",
  "type": "doc"
}
---
Comment 945 on to-do 612: design templates on their own before the plan builder. A template is generic: a prompt put in front of any resource. Plans are its first use.

## What a template is
A template is a project-wide resource, beside docs and designs. Its title names it ("Functional design, then technical implementation"). Its brief is the instructions: the prompt the agent reads before working on anything made from it. It can also carry sections, used as a skeleton that a new resource starts with. A template says which types it applies to, for example plan or todo; an empty list means any type. Anyone can write one, from the viewer or with journal template create.

## Applying one
Any resource can name its template when it is created: journal plan create "..." --set template=3, or picked in the viewer's New dialog. Applying a template does two things. The resource starts with the template's sections (for a plan: its phases, each with its complete-when line and checkpoint). The resource also keeps a link to the template, so the viewer shows which template it follows, and a later edit to the template reaches every resource that follows it. A template applies only when the resource is created; it is never swapped in later.

## How the agent is told
The template's instructions come first whenever the agent picks up something made from it. They appear above the output of journal <type> show <n>. They are whispered once when work starts on the resource, or on a row under a plan made from it. They come back after a compaction, with the rest of the open work. The instructions are the preamble; the resource is what follows. The template is never copied into the resource's own text, so the user's words and the template's words stay apart.

## In the viewer
Templates get a page under Project, like Documents and Designs: a list, and the one-component panel used for every resource, to read and edit one. Every New dialog that creates a type a template applies to gets a Template choice (Blank, or a template). The inspector of a resource made from a template shows the template as a link at the top.

## Plans first
The plan builder (to-do 612) is the first user of templates. New plan asks: Blank, or From a template. Either way the plan is written with the agent, never by hand. The journal ships two plan templates: Blank (the plan skill's usual steps) and Functional design, then technical implementation. The second one is Redmar's case: a functional phase in which the agent researches the feature and writes a functional doc for the designer to approve at a checkpoint, then a technical phase in which the developer turns it into to-dos and builds them.

## Left open
Phase owners. In Redmar's case, the functional phase belongs to the designer and the technical phase to the developer. The journal knows only one user today, so an owner can only be a label on a phase until it knows more people (the cloud workspace). I have left owners out of the first templates. The phase brief can still say who the phase is for.

## To-dos
1. Template resource type, owned by a templates feature: create, show, update, applies_to. 2. Apply a template when a resource is created: --set template=<n>, skeleton sections copied, link kept. 3. Preamble: the template's instructions above show, whispered when work starts, carried after a compaction. 4. Templates page in the viewer. 5. Template choice in the viewer's New dialogs. 6. The two plan templates the journal ships. Then to-do 612, the plan builder.
