Get the FREE Ultimate OpenClaw Setup Guide →

add-doc

npx machina-cli add skill brennacodes/brenna-plugs/add-doc --openclaw
Files (1)
SKILL.md
9.2 KB
<purpose> Capture a structured document from the current conversation context. Automatically determines the best document structure (decision doc, technical reference, discussion summary, how-to guide, or architecture doc), generates tags for discoverability, and writes to `.things/for-the-record/docs/`. See `references/doc-format.md` for the frontmatter schema and document structures. </purpose> <steps> <step id="load-config" number="1"> <description>Load Configuration</description>
<load-config>
  <action>Resolve the user's home directory.</action>
  <command language="bash" output="home" tool="Bash">echo $HOME</command>
  <constraint>Never pass `~` to the Read tool.</constraint>

  <read path="<home>/.things/config.json" output="config" />
  <if condition="config-missing">Tell the user: "Run `/things:setup-things` first." Then stop.<exit /></if>

  <read path="<home>/.things/for-the-record/preferences.json" output="preferences" />
  <if condition="preferences-missing">Tell the user: "Run `/setup-ftr` first." Then stop.<exit /></if>
</load-config>
</step> <step id="parse-arguments" number="2"> <description>Parse Arguments</description>
<action>Parse `$ARGUMENTS` for:</action>
- **topic**: The subject to document (everything that isn't a flag)
- **--detailed**: Override detail level to `detailed`
- **--tags tag1,tag2**: Explicit tags to include (comma-separated)

<action>Set `detail_level` from `--detailed` flag or fall back to `preferences.default_detail_level`.</action>
</step> <step id="gather-context" number="3"> <description>Gather Context from Conversation</description>
<action>Search the conversation history for content relevant to the topic. Scope to the topic if one was provided.</action>

<constraint>
What counts as documentable context:
- Technical discussions, decisions, architecture plans
- Problem-solving sessions with conclusions
- How-to walkthroughs or setup procedures
- Design evaluations with tradeoffs
- Configuration or integration details
- Explanations of systems, patterns, or approaches
</constraint>

<if condition="no-useful-context">
  <ask-user-question>
    <question>I don't see relevant context in our conversation for "{topic}". What would you like to document?</question>
  </ask-user-question>
</if>

<if condition="topic-not-provided-and-context-ambiguous">
  <ask-user-question>
    <question>What would you like to capture as a document? I can see a few threads in our conversation.</question>
  </ask-user-question>
</if>
</step> <step id="choose-structure" number="4"> <description>Choose Document Structure</description>
<action>Based on the gathered context, auto-choose the best document structure:</action>

| Content Pattern | Structure |
|----------------|-----------|
| Weighed options, chose an approach | Decision Doc: Context → Options → Evaluation → Decision → Rationale |
| Explained a system, API, or tool | Technical Reference: Overview → Details → Usage → Caveats |
| Discussed a topic, reached conclusions | Discussion Summary: Topic → Key Points → Conclusions → Open Questions |
| Walked through steps to accomplish something | How-To Guide: Goal → Prerequisites → Steps → Verification |
| Designed a system or component | Architecture Doc: Overview → Components → Data Flow → Constraints |

<constraint>If the content doesn't clearly fit one structure, pick the closest match. Don't ask the user to choose — the auto-selection should be good enough. If genuinely ambiguous between two, briefly mention which you chose and why.</constraint>
</step> <step id="compose-document" number="5"> <description>Compose the Document</description>
<action>Write the document body using the chosen structure.</action>

<constraint>
Detail level controls depth:
- **concise**: Key points, decisions, outcomes. 1-2 paragraphs per section. Code blocks only when essential. Strip tangential discussion.
- **detailed**: Full reasoning chains, all alternatives discussed, complete code blocks, edge cases, caveats, and context that future-you needs. Preserve the richness of the conversation.
</constraint>

<constraint>Preserve specificity. "Configured app's prompt routing to use XML workflow tags" is better than "set up the system." Capture project names, tool names, version numbers, file paths, and configuration details.</constraint>
</step> <step id="generate-tags" number="6"> <description>Generate Tags</description>
<if condition="preferences.auto_tag == true">
  <action>Auto-generate tags by combining:</action>
  - Technologies and tools mentioned (e.g., `rust`, `python`, `claude-code`)
  - Domain keywords (e.g., `architecture`, `security`, `performance`)
  - Activity type (e.g., `decision`, `reference`, `how-to`)
  - Project names mentioned
  - Any explicit `--tags` from arguments

  <action>Read existing `<home>/.things/for-the-record/tags.json` and cross-reference for consistency. Prefer existing tag spellings over new variations (e.g., use `claude-code` if it exists rather than creating `claude_code`).</action>

  <action>Also check `<home>/.things/tags/index.json` (central tag index) for cross-plugin tag consistency.</action>
</if>

<if condition="preferences.auto_tag == false">
  <action>Use only explicit `--tags` from arguments. If none provided, ask.</action>
</if>

<ask-user-question>
  <question>Here are the generated tags for this document. Add, remove, or modify:</question>
  <option>Looks good</option>
  <option-with-text-input>Make changes</option-with-text-input>
</ask-user-question>
</step> <step id="generate-filename" number="7"> <description>Generate Filename</description>
<action>Generate filename: `<YYYY-MM-DD>-<slugified-topic>.md`</action>

<constraint>Slugify: lowercase, replace spaces and special chars with hyphens, collapse multiple hyphens, trim to reasonable length (~60 chars max for the slug portion).</constraint>

<action>Check if file already exists at `<home>/.things/for-the-record/docs/<filename>`.</action>
<if condition="file-exists">
  <ask-user-question>
    <question>A document with this name already exists. What would you like to do?</question>
    <option>Replace it</option>
    <option-with-text-input>Use a different name</option-with-text-input>
  </ask-user-question>
</if>
</step> <step id="write-document" number="8"> <description>Write Document</description>
<write path="<home>/.things/for-the-record/docs/<filename>">

<constraint>Use the frontmatter schema from `references/doc-format.md`.</constraint>

<template name="document">
```markdown
---
title: "<title>"
date: <YYYY-MM-DD>
description: "<1-2 sentence summary>"
detail_level: "<concise|detailed>"
source_type: "conversation"
tags: [<tags>]
---

<document body using chosen structure>
```
</template>

</write>
</step> <step id="rebuild-index" number="9"> <description>Rebuild Index</description>
<constraint>The things PostToolUse hook automatically dispatches `rebuild-index.py` via the registry after writing a doc file. No manual rebuild needed.</constraint>

<if condition="hook-did-not-fire">The rebuild can be run manually:
  <command language="bash" tool="Bash">python3 <plugin_root>/scripts/rebuild-index.py $HOME/.things</command>
</if>
</step> <step id="git-workflow" number="10"> <description>Handle Git Workflow</description>
<git-workflow>
  <action>Pull latest before committing.</action>
  <command language="bash" tool="Bash">git -C <home>/.things pull --rebase 2>/dev/null || true</command>

  <action>Read git workflow from `config.json` (`git.workflow`).</action>

  <if condition="workflow-auto">Automatically `git add`, `git commit -m "doc: <title>"`, and `git push`.</if>
  <if condition="workflow-ask">
    <ask-user-question>
      <question>Commit and push this document?</question>
      <option>Yes -- commit and push</option>
      <option>Commit only</option>
      <option>No -- I'll handle git myself</option>
    </ask-user-question>
  </if>
  <if condition="workflow-manual">Tell the user the file has been saved.</if>
</git-workflow>
</step> <step id="confirm" number="11"> <description>Confirm</description>
<completion-message>
Captured: **<title>** (`<detail_level>`, `<structure_type>`)
Location: `<home>/.things/for-the-record/docs/<filename>`
Tags: `<tags>`

Find it later: `/things:search-things --tag <tag>` or `/things:search-things <keyword>`
</completion-message>
</step> </steps>

Source

git clone https://github.com/brennacodes/brenna-plugs/blob/main/plugins/for-the-record/skills/add-doc/SKILL.mdView on GitHub

Overview

add-doc captures structured documentation from conversation context. It automatically determines the best document structure (decision doc, technical reference, discussion summary, how-to guide, or architecture doc), generates discoverable tags, and writes to .things/for-the-record/docs/ for easy cross-reference.

How This Skill Works

The skill loads user configuration from the home directory and preferences to determine the detail level, parses the topic and flags from ARGUMENTS, gathers relevant context from the conversation, auto-selects the most appropriate document structure using content patterns (e.g., decision, technical reference, discussion summary, how-to, architecture), generates tags, and writes the document with the frontmatter schema defined in references/doc-format.md to .things/for-the-record/docs/.

When to Use It

  • When you need to record a design decision from a discussion.
  • When documenting a system, API, or tool as a Technical Reference.
  • When summarizing a multi-turn conversation or meeting.
  • When creating a how-to guide or setup procedure.
  • When documenting architecture decisions and data flow.

Quick Start

  1. Step 1: Load configuration and user preferences from the home directory (e.g., ~/.things/config.json and ~/.things/for-the-record/preferences.json).
  2. Step 2: Parse arguments to identify the topic, detail level, and any --tags provided.
  3. Step 3: Gather context from the conversation, auto-choose the document structure, generate tags, and write the document to .things/for-the-record/docs/ with the frontmatter.

Best Practices

  • Clearly define the topic up front so add-doc can select the right structure.
  • Provide or let add-doc infer a reasonable level of detail based on context.
  • Optionally supply explicit tags with --tags for easier discovery.
  • Verify the chosen structure aligns with the documented content pattern (decision, tech ref, etc.).
  • Store the output in .things/for-the-record/docs/ with a consistent naming scheme.

Example Use Cases

  • Decision Doc: Choosing a caching strategy for the API gateway (Context → Options → Evaluation → Decision → Rationale).
  • Technical Reference: Overview and usage details for the User Service API.
  • Discussion Summary: Trade-offs discussed in database migration plan.
  • How-To Guide: Step-by-step deployment of a new microservice to the staging environment.
  • Architecture Doc: Data flow, components, and constraints of the event-driven pipeline.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers