Skip to content

Annotation Guide

How to annotate TypeScript and Gherkin files for pattern extraction, documentation generation, and architecture diagrams.

For the complete tag reference (all 50+ tags with formats, values, and examples), generate the taxonomy: npx generate-tag-taxonomy -o TAG_TAXONOMY.md -f or see TAXONOMY.md for the taxonomy architecture.


Every file that participates in the annotation system must have a @libar-docs opt-in marker. Files without this marker are invisible to the scanner.

TypeScript — file-level JSDoc block:

/**
* @libar-docs
* @libar-docs-pattern MyPattern
* @libar-docs-status roadmap
* @libar-docs-uses EventStore, CommandBus
*
* ## My Pattern - Description
*
* Paragraph describing the pattern's purpose.
*/

Gherkin — file-level tags before Feature::

@libar-docs
@libar-docs-pattern:MyPattern
@libar-docs-status:roadmap
@libar-docs-phase:14
@libar-docs-depends-on:EventStore,CommandBus
Feature: My Pattern
**Problem:**
Description of the problem.

The tag prefix is configurable via presets. All examples in this guide use the default @libar-docs- prefix.

PresetPrefixCategoriesUse Case
libar-generic (default)@libar-docs-3Simple projects
ddd-es-cqrs@libar-docs-21DDD/Event Sourcing monorepos
generic@docs-3Simple projects, short prefix

See CONFIGURATION.md for preset details and custom configuration.

Annotations are split between TypeScript and Gherkin by domain:

SourceOwnsExample Tags
TypeScriptImplementation: runtime deps, category, shapesuses, used-by, extract-shapes, shape
GherkinPlanning: status, phase, timeline, dependenciesstatus, phase, depends-on, quarter

Anti-pattern validation enforces these boundaries — see VALIDATION.md.


Shape extraction pulls TypeScript type definitions (interfaces, type aliases, enums, functions, consts) into generated documentation. There are three modes:

List specific declaration names in the file-level JSDoc:

/**
* @libar-docs
* @libar-docs-extract-shapes MasterDatasetSchema, StatusGroupsSchema, RelationshipEntry
*/

Names appear in the generated output in the order listed.

Extract all exported declarations automatically:

/**
* @libar-docs
* @libar-docs-extract-shapes *
*/

Wildcard must be the sole value — *, Foo is invalid.

Tag individual declarations with @libar-docs-shape, optionally with a group name:

/** @libar-docs-shape api-types */
export interface CommandInput {
readonly aggregateId: string;
readonly payload: unknown;
}
/** @libar-docs-shape api-types */
export type CommandResult = Result<void, CommandError>;

Declaration-level shapes work on both exported and non-exported declarations. The optional group name (api-types) enables filtering in diagram scopes and product area documents via @libar-docs-include.

For Zod files, extract the schema constant (with Schema suffix), not the inferred type alias:

Wrong (type alias)Correct (schema constant)
@extract-shapes MasterDataset@extract-shapes MasterDatasetSchema
Shows: z.infer<typeof ...> (unhelpful)Shows: z.object({...}) (full structure)

/**
* @libar-docs
* @libar-docs-pattern MasterDataset
* @libar-docs-status completed
* @libar-docs-extract-shapes MasterDatasetSchema, StatusGroupsSchema, PhaseGroupSchema
*/
/**
* @libar-docs
* @libar-docs-pattern DocumentGenerator
* @libar-docs-status completed
* @libar-docs-extract-shapes DocumentGenerator, GeneratorContext, GeneratorOutput
*/
/**
* @libar-docs
* @libar-docs-pattern TransformDataset
* @libar-docs-status completed
* @libar-docs-arch-context generator
* @libar-docs-arch-layer application
* @libar-docs-extract-shapes transformToMasterDataset, RuntimeMasterDataset
*/
@libar-docs
@libar-docs-pattern:ProcessGuardLinter
@libar-docs-status:roadmap
@libar-docs-phase:99
@libar-docs-depends-on:StateMachine,ValidationRules
Feature: Process Guard Linter
Background: Deliverables
Given the following deliverables:
| Deliverable | Status | Location |
| State derivation | Pending | src/lint/derive.ts |
Rule: Completed specs require unlock reason
**Invariant:** A completed spec cannot be modified without explicit unlock.
**Rationale:** Prevents accidental regression of validated work.
@acceptance-criteria @happy-path
Scenario: Reject modification without unlock
Given a spec with status "completed"
When I modify a deliverable
Then validation fails with "completed-protection"

Tags are organized into 12 functional groups. This table shows representative tags per group — for the complete reference with all formats, values, and examples, run npx generate-tag-taxonomy -o TAG_TAXONOMY.md -f.

GroupTags (representative)Format Types
Corepattern, status, core, briefvalue, enum, flag
Relationshipuses, used-by, implements, depends-oncsv, value
Processphase, quarter, effort, team, prioritynumber, value, enum
PRDproduct-area, user-role, business-valuevalue
ADRadr, adr-status, adr-category, adr-themevalue, enum
Hierarchylevel, parent, titleenum, value, quoted-value
Traceabilityexecutable-specs, roadmap-spec, behavior-filecsv, value
Discoverydiscovered-gap, discovered-improvementvalue (repeatable)
Architecturearch-role, arch-context, arch-layer, includeenum, value, csv
Extractionextract-shapes, shapecsv, value
Stubtarget, sincevalue
Conventionconventioncsv (enum values)
FormatSyntax ExampleParsing
flag@libar-docs-coreBoolean presence (no value)
value@libar-docs-pattern FooSimple string
enum@libar-docs-status roadmapConstrained to predefined list
csv@libar-docs-uses A, B, CComma-separated values
number@libar-docs-phase 14Numeric value
quoted-value@libar-docs-title:'My Title'Preserves spaces in value

Terminal window
# Tag usage inventory (counts per tag and value)
pnpm process:query -- tags
# Find files missing @libar-docs opt-in marker
pnpm process:query -- unannotated --path src/types
# File inventory by type (TS, Gherkin, Stubs)
pnpm process:query -- sources
# Full pattern JSON including extractedShapes
pnpm process:query -- query getPattern MyPattern
# Generate complete tag reference
npx generate-tag-taxonomy -o TAG_TAXONOMY.md -f
SymptomCauseFix
Pattern not in scanner outputMissing @libar-docs opt-in markerAdd file-level @libar-docs JSDoc/tag
Shape shows z.infer<> wrapperExtracted type alias, not schemaUse schema constant name (e.g., FooSchema)
Shape not in product area docMissing @libar-docs-product-areaAdd product-area tag to file-level annotation
Declaration-level shape missingNo @libar-docs-shape on declAdd @libar-docs-shape JSDoc to the declaration
Tag value rejectedWrong format or invalid enum valueCheck format type in taxonomy reference
Anti-pattern validation errorTag on wrong source typeMove tag to correct source (TS vs Gherkin)

TopicDocument
Taxonomy architectureTAXONOMY.md
Presets and configurationCONFIGURATION.md
Pipeline and codecsARCHITECTURE.md
Gherkin writing patternsGHERKIN-PATTERNS.md
Anti-pattern validationVALIDATION.md
Product area enrichmentCLAUDE.md — Product Area Guide