Skip to content

docs: reorganize RTK documentation into 3-tab structure (guide/reference/architecture)#1029

Open
FlorianBruniaux wants to merge 9 commits intodevelopfrom
feat/refac-doc
Open

docs: reorganize RTK documentation into 3-tab structure (guide/reference/architecture)#1029
FlorianBruniaux wants to merge 9 commits intodevelopfrom
feat/refac-doc

Conversation

@FlorianBruniaux
Copy link
Copy Markdown
Collaborator

What

Reorganizes RTK's documentation from 20+ scattered markdown files into a structured 3-tab layout ready to feed the rtk-ai/rtk-website Astro pipeline.

Why

The current docs/ directory is a flat collection of FR/EN mixed files with no hierarchy, no frontmatter, and no structure that a static site generator can consume. This PR establishes the interface contract that prepare-docs.mjs (rtk-website) validates at build time.

What changed

No existing files were modified. All changes are additive.

Interface contract

  • docs/README.md — defines 3-tab structure, required frontmatter schema, naming conventions, and cross-tab link format

Tab 1: docs/guide/ — 23 pages

User-facing documentation, adapted from existing sources (FEATURES.md, INSTALL.md, AUDIT_GUIDE.md, filter-workflow.md, hooks/*/README.md, TROUBLESHOOTING.md):

  • getting-started/ — installation, quick-start (5-min walkthrough), supported-agents (9 agents, 3 integration tiers)
  • commands/ — git, cargo, files, javascript, python, go, ruby, dotnet, containers, github-cli, data, utilities
  • filters/ — using-filters (8-stage pipeline, Mermaid), creating-filters (TOML DSL guide)
  • analytics/ — gain (rtk gain full reference), discover, economics
  • configuration.md, troubleshooting.md

Tab 2: docs/reference/ — 10 pages

Contributor and technical documentation, distilled from CONTRIBUTING.md, SECURITY.md, ARCHITECTURE.md, .claude/rules/:

  • contributing/ — guide (design philosophy, PR process, TOML vs Rust decision matrix), security (vulnerability policy, dangerous patterns), coding-standards (Rust rules, fallback pattern), testing (snapshot tests, token accuracy, benchmarks)
  • internals/ — command-routing (6-phase lifecycle), filter-pipeline (12 strategies), tracking-system (SQLite schema, Tracker API), hook-engine (rewrite registry, exit code contract)
  • toml-dsl/ — specification (complete field reference, pipeline order, build compilation)

Tab 3: docs/architecture/ — 5 pages

  • diagrams/ — command-flow (end-to-end Mermaid: hook → RTK → LLM), filter-pipeline (build + runtime Mermaid)
  • decisions/ — why-no-async (ADR: single-threaded, <10ms constraint), proxy-architecture (ADR: CLI proxy vs aliases vs LD_PRELOAD)

Validation

Every page carries valid YAML frontmatter (title, description, sidebar.order) as required by the interface contract. The structure passes the prepare-docs.mjs gate: 3 tabs exist, each has an index.md, all internal links use relative paths.

What this enables

Once merged to develop and then master, the rtk-website build pipeline can clone this repo, copy docs/ to src/content/docs/, and serve a full 3-tab Starlight documentation site with zero manual intervention.

Out of scope

  • docs/FEATURES.md deprecation notice (follow-up PR)
  • i18n: docs are EN-only by design. Starlight's defaultLocale: 'en' config will allow adding /fr/, /es/ routes later with no URL restructuring needed.

🤖 Generated with Claude Code

aeppling and others added 9 commits March 30, 2026 15:13
fix(refacto-codebase): technical docs & sub folders
…-components--rtk

chore(master): release 0.34.2
fix(refacto): wrappers for standardization, exit codes lexer tokenizer, constants, code clean
…-components--rtk

chore(master): release 0.34.3
Creates docs/README.md (interface contract defining 3-tab structure,
required frontmatter, and conventions) and 4 stub pages with valid
frontmatter for docs/guide/, docs/reference/, and docs/architecture/.
These are the prerequisites for the prepare-docs.mjs pipeline (Plan B)
and for Adrien's Phase 1 content work.

No existing files modified.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Florian BRUNIAUX <florian@bruniaux.com>
Creates the complete user-facing guide for the docs website:

Getting started:
- quick-start.md: 5-minute walkthrough (init, first commands, rtk gain)
- supported-agents.md: Claude Code, Cursor, Copilot, Gemini, Cline, Windsurf,
  Codex, OpenCode — integration tiers, install commands, graceful degradation

Commands (adapted from FEATURES.md, English, --help-first format):
- git.md: status/log/diff/show/add/commit/push/pull/branch + gh CLI
- cargo.md: test/nextest/build/check/clippy/install + generic test/err wrappers
- files.md: ls/read/grep/find/diff/wc/smart with before/after examples
- javascript.md: vitest/playwright/tsc/eslint/prettier/next/pnpm/npm/npx/prisma
- python.md: pytest/ruff/mypy/pip/deps

Reference:
- filters/using-filters.md: 8-stage pipeline, lookup priority, TOML DSL reference,
  Mermaid diagram (adapted from docs/filter-workflow.md)
- analytics/gain.md: rtk gain flags, daily/weekly/monthly breakdowns, export
  formats, token estimation, database management (from docs/AUDIT_GUIDE.md)
- configuration.md: full config.toml reference, env vars, tee system, telemetry
- troubleshooting.md: common issues and fixes (from docs/TROUBLESHOOTING.md)

All pages carry valid frontmatter (title, description, sidebar.order).
No existing files modified.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Florian BRUNIAUX <florian@bruniaux.com>
…mmands

Guide — 10 new command and analytics pages:
- commands/go.md: go test (NDJSON), golangci-lint
- commands/ruby.md: rspec, rubocop, rake
- commands/dotnet.md: dotnet build/test, binlog, format
- commands/containers.md: docker ps/images/logs/compose, kubectl pods/services/logs
- commands/github-cli.md: gh pr/issue/run, Graphite gt commands
- commands/data.md: json, env, log, curl, wget, aws, psql, summary
- commands/utilities.md: proxy passthrough, global flags, RTK_DISABLED
- filters/creating-filters.md: TOML DSL guide, field reference, inline tests
- analytics/discover.md: rtk discover — missed savings analysis
- analytics/economics.md: rtk cc-economics — dollar savings vs ccusage

Reference tab (9 pages):
- contributing/guide.md: design philosophy, PR process, TOML vs Rust decision
- contributing/security.md: vulnerability reporting, dangerous patterns, dep criteria
- contributing/coding-standards.md: Rust rules, error handling, lazy_static, fallback pattern
- contributing/testing.md: snapshot tests, token accuracy, cross-platform, benchmarks
- internals/command-routing.md: 6-phase lifecycle, exit codes, verbosity, module map
- internals/filter-pipeline.md: 12 filtering strategies, TOML stages, savings by ecosystem
- internals/tracking-system.md: SQLite schema, data flow, token estimation, Tracker API
- internals/hook-engine.md: rewrite registry, compound commands, exit code contract, rtk init
- toml-dsl/specification.md: complete field reference, pipeline order, build compilation

Architecture tab (4 pages):
- diagrams/command-flow.md: end-to-end Mermaid — hook → RTK → LLM
- diagrams/filter-pipeline.md: build pipeline + 8-stage runtime Mermaid
- decisions/why-no-async.md: ADR — single-threaded, <10ms startup constraint
- decisions/proxy-architecture.md: ADR — why CLI proxy over aliases/LD_PRELOAD/hooks-only

All pages carry valid frontmatter (title, description, sidebar.order).
No existing files modified.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Florian BRUNIAUX <florian@bruniaux.com>
Copilot AI review requested due to automatic review settings April 4, 2026 22:24
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
2 out of 3 committers have signed the CLA.

✅ aeppling
✅ FlorianBruniaux
❌ github-actions[bot]
You have signed the CLA already but the status is still pending? Let us recheck it.

@FlorianBruniaux
Copy link
Copy Markdown
Collaborator Author

FlorianBruniaux commented Apr 4, 2026

i18n docs — two options, need input

Before this merges, worth aligning on how we handle multi-language docs down the road. The current structure is EN-only (explicit decision in Plan B), but the question is whether we set it up to be migration-friendly.

Option A — locale subdirectory at docs/ root

docs/
  en/         ← current content moved here
    guide/
    reference/
    architecture/
  fr/
    guide/
    ...

prepare-docs.mjs copies docs/en/ as the root locale (keeps /docs/guide/git URLs for EN) and docs/fr/ as /fr/docs/guide/git. Starlight handles this natively.

Upside: clean, native Starlight i18n, no URL changes for EN.
Downside: requires moving all current files under docs/en/ — easy one-liner (git mv) but has to happen before content work piles up.

Option B — EN-only in repo, translations externalized

docs/         ← EN only, current structure unchanged

Translations live on Crowdin/Weblate or a separate repo. prepare-docs.mjs injects them at build time. Community translates on the platform, not via Rust PRs.

Upside: zero impact on current structure, zero maintenance burden until there's actual demand.
Downside: external dependency, slightly more build pipeline complexity when we do add a language.

My take: Option B now, Option A when a specific language has contributors ready to maintain it. Migration is a one-liner at that point. No reason to restructure prematurely.

@pszymkowiak @aeppling — what's your preference? If you want Option A, better to decide before Adrien starts filling in content so we're not doing a mass rename mid-sprint.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new structured documentation layout under docs/ intended for consumption by the rtk-ai/rtk-website pipeline (Guide / Reference / Architecture), and also includes release/version metadata updates.

Changes:

  • Add a large set of new docs pages with required frontmatter, organized into docs/guide/, docs/reference/, and docs/architecture/.
  • Add diagrams (Mermaid) and ADR-style architecture decision pages.
  • Update release/version files (CHANGELOG.md, Cargo.toml, Cargo.lock, .release-please-manifest.json).

Reviewed changes

Copilot reviewed 42 out of 43 changed files in this pull request and generated 20 comments.

Show a summary per file
File Description
docs/README.md Defines the 3-tab docs structure and frontmatter/linking contract.
docs/guide/index.md Guide landing page linking to key user-facing sections.
docs/guide/getting-started/installation.md Installation + verification instructions.
docs/guide/getting-started/quick-start.md 5-minute walkthrough for initial usage.
docs/guide/getting-started/supported-agents.md Lists supported agents and integration tiers.
docs/guide/configuration.md User-facing config and env var reference.
docs/guide/troubleshooting.md Common issues and fixes.
docs/guide/filters/using-filters.md Explains TOML filters, lookup order, and pipeline (contains schema details).
docs/guide/filters/creating-filters.md Walkthrough for writing project-local TOML filters.
docs/guide/commands/git.md Git command behavior and savings examples.
docs/guide/commands/cargo.md Cargo command behavior and wrappers.
docs/guide/commands/files.md Filesystem/search command behaviors.
docs/guide/commands/javascript.md JS/TS ecosystem commands and examples.
docs/guide/commands/python.md Python ecosystem commands and examples.
docs/guide/commands/go.md Go ecosystem commands and examples.
docs/guide/commands/ruby.md Ruby ecosystem commands and examples.
docs/guide/commands/dotnet.md .NET ecosystem commands and examples.
docs/guide/commands/containers.md Docker/Kubernetes command behaviors.
docs/guide/commands/data.md JSON/env/log/curl/wget/aws/psql/summary commands.
docs/guide/commands/github-cli.md gh/gt behaviors and examples.
docs/guide/commands/utilities.md Proxy passthrough + global flags.
docs/guide/analytics/gain.md rtk gain usage and data model explanation.
docs/guide/analytics/discover.md rtk discover usage and output explanation.
docs/guide/analytics/economics.md rtk cc-economics usage explanation.
docs/reference/index.md Reference tab landing page.
docs/reference/contributing/guide.md Contributor guide distilled for the docs site.
docs/reference/contributing/security.md Security policy + dangerous patterns guidance.
docs/reference/contributing/coding-standards.md RTK-specific Rust coding standards.
docs/reference/contributing/testing.md Testing approaches (insta, savings checks, perf).
docs/reference/internals/command-routing.md High-level routing lifecycle explanation.
docs/reference/internals/filter-pipeline.md Overview of filter strategies + TOML pipeline.
docs/reference/internals/tracking-system.md SQLite tracking system explanation (schema/paths/etc.).
docs/reference/internals/hook-engine.md Hook/rewrite architecture and contracts.
docs/reference/toml-dsl/specification.md TOML DSL “specification” reference page.
docs/architecture/index.md Architecture tab landing page.
docs/architecture/diagrams/command-flow.md Mermaid diagram for end-to-end command flow.
docs/architecture/diagrams/filter-pipeline.md Mermaid diagram for TOML filter build/runtime pipeline.
docs/architecture/decisions/why-no-async.md ADR documenting “no async runtime” rationale.
docs/architecture/decisions/proxy-architecture.md ADR documenting the CLI proxy pattern decision.
CHANGELOG.md Adds release entries for 0.34.2 and 0.34.3.
Cargo.toml Bumps crate version to 0.34.3.
Cargo.lock Updates locked package version to 0.34.3.
.release-please-manifest.json Updates release-please tracked version to 0.34.3.

Comment on lines +51 to +55
[[filters]]
name = "my-tool"
match_command = "^my-tool\\b"

strip_lines = [
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TOML example uses [[filters]] with a name field and strip_lines, but RTK's TOML engine expects schema_version = 1 at the top and filter definitions under [filters.<filter-name>] with fields like strip_lines_matching / keep_lines_matching (see src/core/toml_filter.rs). As written, this example will fail to parse and the filter will be ignored.

Suggested change
[[filters]]
name = "my-tool"
match_command = "^my-tool\\b"
strip_lines = [
schema_version = 1
[filters.my-tool]
match_command = "^my-tool\\b"
strip_lines_matching = [

Copilot uses AI. Check for mistakes.
S1["1. strip_ansi"] --> S2
S2["2. replace"] --> S3
S3{"3. match_output\nshort-circuit?"}
S3 -->|"✅ match"| MSG[["emit on_match\nstop"]]
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the runtime pipeline diagram, match_output is shown emitting on_match, but the TOML schema uses match_output = [{ pattern, message, unless? }] and there is no on_match field (see src/core/toml_filter.rs). The diagram should reference the rule’s message instead.

Suggested change
S3 -->|"✅ match"| MSG[["emit on_match\nstop"]]
S3 -->|"✅ match"| MSG[["emit rule message\nstop"]]

Copilot uses AI. Check for mistakes.
Comment on lines +14 to +18
**Storage locations:**
- Linux: `~/.local/share/rtk/tracking.db`
- macOS: `~/Library/Application Support/rtk/tracking.db`
- Windows: `%APPDATA%\rtk\tracking.db`

Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DB filename/location here doesn’t match the current implementation: the tracker uses dirs::data_local_dir()/rtk/history.db by default (not tracking.db), and on Windows it’s under LocalAppData (not %APPDATA%). Please update the paths to match src/core/tracking.rs (HISTORY_DB = "history.db").

Copilot uses AI. Check for mistakes.
Comment on lines +69 to +73
```
estimate_tokens(text) = text.len() / 4
```

~4 characters per token average. Accuracy: ±10% vs actual LLM tokenization.
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Token estimation is described as text.len() / 4, but the implementation uses ceil(chars/4) (so 1–4 chars still counts as 1 token) in estimate_tokens (src/core/tracking.rs). Please update the formula here to avoid confusion when validating numbers.

Copilot uses AI. Check for mistakes.
Comment on lines 1 to 4
[package]
name = "rtk"
version = "0.34.1"
version = "0.34.3"
edition = "2021"
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR description says “No existing files were modified” and “All changes are additive”, but this PR changes the crate version (and also updates CHANGELOG/Cargo.lock/release manifest). If the version bump is intentional, please update the PR description; otherwise, consider dropping these release/version changes from this docs-only PR.

Copilot uses AI. Check for mistakes.
Comment on lines +25 to +29
[tracking]
enabled = true # enable/disable token tracking
history_days = 90 # retention in days (auto-cleanup)
database_path = "/custom/path/tracking.db" # optional override

Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs imply tracking.history_days controls retention, but Tracker::cleanup_old() uses DEFAULT_HISTORY_DAYS and doesn’t read config (src/core/tracking.rs). Consider clarifying this (or implementing config-driven retention) so the config docs match runtime behavior.

Copilot uses AI. Check for mistakes.

| Variable | Description |
|----------|-------------|
| `RTK_DISABLED=1` | Disable RTK for a single command (`RTK_DISABLED=1 git status`) |
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The env var table is missing RTK_DB_PATH, which overrides the tracking DB location with highest priority (src/core/tracking.rs). Adding it here would make configuration docs complete.

Suggested change
| `RTK_DISABLED=1` | Disable RTK for a single command (`RTK_DISABLED=1 git status`) |
| `RTK_DISABLED=1` | Disable RTK for a single command (`RTK_DISABLED=1 git status`) |
| `RTK_DB_PATH` | Override the tracking database path |

Copilot uses AI. Check for mistakes.
Comment on lines +89 to +92
ELSE 0 END
),
exec_time_ms INTEGER
);
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This schema omits columns that RTK adds via migrations (exec_time_ms and project_path) and also has timestamp populated by RTK (not a DEFAULT). Please update the schema snippet to reflect the actual CREATE TABLE + migrations in src/core/tracking.rs so readers can query the DB correctly.

Copilot uses AI. Check for mistakes.
Comment on lines +118 to +120
## Thread safety

Single-threaded execution with `Mutex<Option<Tracker>>` for future-proofing. No multi-threading currently used.
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The “Thread safety” note mentions Mutex<Option<Tracker>>, but the current implementation doesn’t use that pattern (it opens connections via Tracker::new() and relies on WAL + busy_timeout for concurrent access). Please update this section to match src/core/tracking.rs.

Copilot uses AI. Check for mistakes.
Comment on lines +49 to +52
| `keep_lines_matching` | regex[] | no | Keep only lines matching at least one pattern |
| `replace` | array | no | Regex substitutions: `{ pattern, replacement }` |
| `match_output` | array | no | Short-circuit rules: `{ pattern, message }` |
| `truncate_lines_at` | int | no | Truncate lines longer than N characters |
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

match_output rules also support an optional unless regex to prevent short-circuiting when errors/warnings are present (see MatchOutputRule in src/core/toml_filter.rs). Documenting unless here would make the spec complete.

Copilot uses AI. Check for mistakes.
@aeppling
Copy link
Copy Markdown
Contributor

aeppling commented Apr 5, 2026

Hey,

Thanks for the documentation rework, since PR #869 we already had the technical documentation , this is maintained in each respective folder per responsability, to ensure easy collaboration and work in specific areas.

We need a clean separation between user documentation : Usage, How to use, How to configure, and so on....
-> online doc

And the technical documentation: How to contribute, Flow Diagrams, Edge case, Engine
-> can be in the codebase in respective areas

This is to keep things simple for users, we do not want noise in those documentation.

Current RTK technical doc implementation

The documentation follows a distributed, co-located pattern - each folder contains a README explaining its purpose:

Root Level Documentation

https://github.com/rtk-ai/rtk/blob/main/docs/contributing/ARCHITECTURE.md (42K)
https://github.com/rtk-ai/rtk/blob/main/CONTRIBUTING.md (12K)
https://github.com/rtk-ai/rtk/blob/main/SECURITY.md (7K)
https://github.com/rtk-ai/rtk/blob/main/docs/TECHNICAL.md (20K) - Created in PR #869

Components level Documentation

https://github.com/rtk-ai/rtk/blob/main/src/core/README.md
https://github.com/rtk-ai/rtk/blob/main/src/hooks/README.md
https://github.com/rtk-ai/rtk/blob/main/src/cmds/README.md
... and so on

Ecosystem-specific READMEs:

https://github.com/rtk-ai/rtk/tree/main/src/cmds/git - Git ecosystem filters
https://github.com/rtk-ai/rtk/tree/main/src/cmds/rust - Rust filters
https://github.com/rtk-ai/rtk/tree/main/src/cmds/js - JavaScript/TypeScript filters
... and so on

Full review

Core Problems

  1. Shows command syntax users never use - Your docs show rtk git status, rtk cargo test, etc. Users don't type these.
  2. Includes code examples
  3. Duplicates existing technical documentation - All technical docs already exist

@FlorianBruniaux
Copy link
Copy Markdown
Collaborator Author

Thanks for the detailed review — the points are valid, taking them seriously.

What you're right about

The reference/ and architecture/ tabs are straight duplicates of what already lives in the codebase (ARCHITECTURE.md, CONTRIBUTING.md, SECURITY.md, component READMEs). No reason to maintain two copies. Those should be cut entirely.

The commands pages showing rtk git status, rtk cargo test, etc. as user-facing commands is wrong. Users don't type those — the hook handles it transparently. Showing that syntax in user docs adds noise and implies a manual workflow that doesn't exist in practice.

What this PR should actually be

User-facing only, minimal scope:

  • getting-started/ — install, verify, hook setup per agent
  • supported-agents.md — which agents work, how to enable each
  • configuration.mdconfig.toml options, env vars, how to exclude commands
  • analytics/gain.md — how to read your savings dashboard
  • troubleshooting.md — common issues and fixes

For the "what does RTK optimize" question: a single page listing ecosystems and savings metrics (no rtk <cmd> syntax, just "git operations: 75-92% savings") is probably enough. Or skip it entirely and let the README handle that.

Proposed next steps

  1. Drop docs/reference/ and docs/architecture/ — already covered in codebase
  2. Rewrite docs/guide/commands/ as a single savings reference page (no CLI syntax) or remove it
  3. Keep the 5 user-facing pages above

Does this align with what you had in mind? Happy to rework the PR scope before Adrien starts on content.

@adrien-epling — also curious what you'd actually want as a user landing on the docs for the first time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants