Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Tags Processor

Purpose

Extracts YAML frontmatter tags from markdown files into a searchable database.

How It Works

Scans .md files for YAML frontmatter blocks (delimited by ---), parses tag metadata, and builds a redb database. The database enables querying files by tags via rsconstruct tags subcommands.

Optionally validates tags against a .tags allowlist file.

Tag Indexing

Two kinds of frontmatter fields are indexed:

  • List fields — each item becomes a bare tag.

    tags:
      - docker
      - python
    

    Produces tags: docker, python.

  • Scalar fields — indexed as key:value (colon separator).

    level: beginner
    difficulty: 3
    published: true
    url: https://example.com/path
    

    Produces tags: level:beginner, difficulty:3, published:true, url:https://example.com/path.

Both inline YAML lists (tags: [a, b, c]) and multi-line lists are supported.

The .tags Allowlist

When a .tags file exists in the project root, the build validates every indexed tag against it. Unknown tags cause a build error with typo suggestions (Levenshtein distance). Wildcard patterns are supported:

# .tags
docker
python
level:beginner
level:advanced
difficulty:*

The pattern difficulty:* matches any tag starting with difficulty:.

Source Files

  • Input: **/*.md
  • Output: out/tags/tags.db

Configuration

[processor.tags]
output = "out/tags/tags.db"            # Output database path
tags_file = ".tags"                    # Allowlist file for tag validation
tags_file_strict = false               # When true, missing .tags file is an error
extra_inputs = []                      # Additional files that trigger rebuilds when changed
KeyTypeDefaultDescription
outputstring"out/tags/tags.db"Path to the tags database file
tags_filestring".tags"Path to the tag allowlist file
tags_file_strictboolfalseFail if the .tags file is missing
extra_inputsstring[][]Extra files whose changes trigger rebuilds

Subcommands

All subcommands require a prior rsconstruct build to populate the database. All support --json for machine-readable output.

Querying

CommandDescription
rsconstruct tags listList all unique tags (sorted)
rsconstruct tags files TAG [TAG...]List files matching all given tags (AND)
rsconstruct tags files --or TAG [TAG...]List files matching any given tag (OR)
rsconstruct tags grep TEXTSearch for tags containing a substring
rsconstruct tags grep -i TEXTCase-insensitive tag search
rsconstruct tags for-file PATHList all tags for a specific file (supports suffix matching)
rsconstruct tags frontmatter PATHShow raw parsed frontmatter for a file
rsconstruct tags countShow each tag with its file count, sorted by frequency
rsconstruct tags treeShow tags grouped by key (e.g. level= group) vs bare tags
rsconstruct tags statsShow database statistics (file count, unique tags, associations)

.tags File Management

CommandDescription
rsconstruct tags initGenerate a .tags file from all currently indexed tags
rsconstruct tags syncAdd missing tags to .tags (preserves existing entries)
rsconstruct tags sync --pruneSync and remove unused tags from .tags
rsconstruct tags add TAGAdd a single tag to .tags
rsconstruct tags remove TAGRemove a single tag from .tags
rsconstruct tags unusedList tags in .tags that no file uses
rsconstruct tags unused --strictSame, but exit with error if any unused tags exist (for CI)
rsconstruct tags validateValidate indexed tags against .tags without rebuilding