Skip to content
Root Files
On this page

How selfdoc generates root-level files like README.md and CLAUDE.md from directive-powered templates in your .stricttools/docs/ directory.

#Root Files

selfdoc can generate root-level project files (like README.md and CLAUDE.md) from templates that live in your .stricttools/docs/ directory. The templates use the same directive syntax as your documentation pages, so the generated files always reflect the current state of your source code.

#How It Works

  1. You create a template in .stricttools/docs/ with an underscore prefix (e.g., .stricttools/docs/_README.md, .stricttools/docs/_CLAUDE.md).
  2. You list those templates in the root_files config array.
  3. When you run selfdoc gen, each template is read, its directives are resolved against your source code, and the result is written to the project root (without the underscore). Generated files are set to mode 444 (read-only) to prevent accidental edits.

So .stricttools/docs/_README.md becomes README.md, and .stricttools/docs/_CLAUDE.md becomes CLAUDE.md.

#Configuration

Add the template paths to root_files in your selfdoc.json. Each entry must be an underscore-prefixed file in .stricttools/docs/ that serves as the template for a root-level project file. The underscore prefix distinguishes templates from regular documentation pages that appear on the built site:

{} json
{
  "root_files": [
    ".stricttools/docs/_README.md",
    ".stricttools/docs/_CLAUDE.md"
  ]
}

Each entry must be an underscore-prefixed file in .stricttools/docs/. The underscore prefix is mandatory -- it distinguishes templates from regular documentation pages.

#Template Format

Templates are regular Markdown files with optional frontmatter and directives. The frontmatter is stripped from the output (it is only used during the build). Everything else -- including resolved directive output -- goes into the generated file.

Example .stricttools/docs/_README.md:

M markdown
++
title = "README template"
++

# MyProject

:<: ref path="mypackage"
:=:
:>:

## Installation

\`\`\`bash
pip install myproject
\`\`\`

After selfdoc gen, the project root gets a README.md with the directive replaced by actual module documentation extracted from source.

#Generated File Markers

Every generated root file starts with an HTML comment header that identifies it as machine-generated and names the source template. This marker serves two purposes: it warns humans not to edit the file directly, and it tells selfdoc that the file is safe to overwrite on the next run:

<!-- Auto-generated by selfdoc from .stricttools/docs/_README.md -- do not edit -->

This header serves two purposes:

  1. It tells humans not to edit the file directly.
  2. It tells selfdoc that the file was previously generated, making it safe to overwrite on the next run.
Warning

If a file exists at the output path and does not have the auto-generated header, selfdoc refuses to overwrite it. This prevents accidentally destroying a hand-written file. Delete or rename the existing file first if you want selfdoc to take over.

#Read-Only Permissions

Generated root files are set to chmod 444 (read-only) after writing. This is a safety measure -- if you or your editor accidentally open the generated file and try to save changes, the OS will block the write. Always edit the template in .stricttools/docs/, never the generated output.

#Regenerating

Run selfdoc gen to regenerate all root files from their templates. This resolves every directive in every template listed in root_files, overwrites the output files, and sets them to read-only permissions. It also runs automatically as part of selfdoc build:

$_ bash
selfdoc gen

This resolves directives in every template listed in root_files and overwrites the output files. It is also run as part of selfdoc build, so your root files stay current whenever you build the docs site.

Tip

If you use rlsbl for releases, add selfdoc gen to your pre-checks hook so root files are always up to date before a release is tagged.

Next: Data Generation -->

More tools from this site

  • claudestream Drive Claude Code from Python: run it as a subprocess and read its output as typed events, with async and sync sessions, sandbox policies, and tools you define in Python
  • claudewheel A TUI Claude Code Launcher that lets you have more than one profile, manage sessions lifecycle, pick the exact CC version, model to use (even older unlisted ones), pick which GitHub account to use, etc.
  • dirstat Fast, single-binary directory statistics CLI: every file under a tree grouped by format, with counts, sizes, and lines of code, as a colored terminal table or as JSON
  • fastware A batteries-included ASGI framework: msgspec JSON, a managed Granian server, dependency injection, SSE, WebSockets, auth, and a test client
  • go-toml-edit Zero-dep TOML editing library for Go with comment preservation
  • howmuchleft The fastest Claude Code statusline: context window, 5-hour, and weekly limit usage as three customizable gradient bars, rendering in about 6 ms
  • orxtra
  • pgdesign
  • predraw Declarative rendering pipeline: describe a scene in JSON and get SVG, PNG and WebP out, with light and dark style tokens, reusable components and text converted to path outlines
  • reposummary Turn a git repository's history into a Markdown journal: pick a time window or revision range and get a readable digest of what changed, optionally narrated by an LLM
  • rlsbl Release orchestration and project scaffolding CLI that bumps versions, validates a structured JSONL changelog, tags only the commit CI verified, and publishes to npm, PyPI, Go and more
  • safegit git wrapper CLI that gives each commit its own temporary index and retries ref updates on conflict, so concurrent agents share one repository
  • saferm Command-line replacement for rm that archives every deletion with a mandatory reason and the context it ran in, so deleted files can be listed, inspected and restored
  • strictcli
  • stricttest An always-on test-isolation floor: a pytest plugin and a Go env-hygiene module that make a test suite structurally unable to reach real credentials, the real HOME, the network, or the development repository.
  • wesktop A Python framework that turns an ASGI web app into a desktop application, serving it from a local Granian server and displaying it in a native OS window via pywebview
Search