# Document a TypeScript Module With a README Using Atlas (2026 Guide)

> Atlas documents a TypeScript module from source: lsp documentSymbol enumerates the real exports, and every README sample is executed before it ships.

To document a TypeScript module with a README, have Atlas write the docs from source rather than from memory. Atlas enumerates the module's real exported surface with the lsp tool's documentSymbol operation, reads the implementation of each export, uses codebase_search to see how callers actually use it, and then emits the README with the write tool. Because every claim comes from a file Atlas just read, the doc is traceable rather than plausible. The signatures quoted in the README are the ones your `tsconfig.json` compiles today, not the ones the module had a year ago, and every code sample is verified by running it with `vitest` or a `pnpm` script before it ships.

## Key takeaways

- The lsp documentSymbol operation reports the TypeScript module's real exported surface, including re-exports and type-only exports.
- codebase_search shows how callers actually use the module, which is what the README examples should show.
- Grep an existing README so a new package matches the repo's heading structure and its `pnpm` install line.
- The write tool shows the full proposed README in the permission prompt before it lands on disk.
- Every code sample is executed with `vitest` before it ships, because an unrun sample is a liability.
- Run `prettier` last so the README's fenced code matches the rest of the repo.

## How does Atlas know what a TypeScript module actually exports?

Atlas enumerates the module's public API with the lsp tool's documentSymbol operation, so no export is missed or invented. A TypeScript barrel file like `src/index.ts` may re-export 30 symbols from 8 files, and documentSymbol lists the real surface rather than the handful the README author remembered.

Re-exports are what make TypeScript documentation drift. A function moved out of `src/client.ts` and re-exported through `src/index.ts` still appears in the package's public API, and a type-only export declared with `export type` is part of the contract even though it disappears at runtime. documentSymbol reports the declarations the language server sees, which is the same set your consumers get from the emitted .d.ts. Atlas indexes code by AST declarations using tree-sitter, not blind line windows, so the enumeration is structural rather than a grep for the word export.

## How do I document how a TypeScript module is actually used?

Atlas reads the implementation of each export, then uses codebase_search to find how callers actually use it in practice. Documented usage and real usage diverge fast: a config object with 9 optional fields is usually called with 2 of them, and the README should show the call that people actually write.

codebase_search is the right instrument because it finds usage by meaning rather than by exact token. Atlas searches code with hybrid semantic and keyword retrieval fused by reciprocal rank fusion, so a function invoked through a destructured import, an aliased name, or a wrapper helper is still found. Reading those real callsites in the repo's own `src/` and test files tells you which parameters matter, which defaults are relied on, and which overload is used in anger. A README built from those examples is immediately useful in a way that a synthesized example never is.

## How do I match the README format the rest of the repo uses?

Atlas greps the repo for an existing README to match heading structure and tone rather than inventing a new format. A TypeScript monorepo where every package under `packages/` already has an Install, Usage, and API README will reject a 12th package that arrives with a different shape.

Consistency across a monorepo is not cosmetic. Consumers scan for the same headings in every package, and tooling that renders docs from the repo often expects the same structure. Atlas greps for the existing README files, reads one or two, and copies the heading order, the code-fence language tags, and whether install instructions use `pnpm` or another manager. The install line is worth getting right specifically: a README in a `pnpm` workspace that tells people to run a different package manager is wrong on the first line, which is where readers give up.

## How does Atlas write the README file safely?

Atlas writes the README with the write tool, quoting real signatures and real file paths. The write tool shows the diff in the permission prompt first, and every Atlas tool call is gated against 3 rule types, allow, ask, and deny, so you read the whole document before it exists on disk.

Reading the proposed README in the permission prompt is the review step that catches invented capability. Look specifically at the signatures: each one should match the declaration documentSymbol reported, including optional parameters and the exact return type your `tsconfig.json` strictness settings produce. Look at the file paths: they should be real paths in `src/`, not plausible ones. Atlas snapshots file changes as git patches, so a README that turns out to describe the module wrongly can be diffed and rolled back rather than hand-edited into shape.

## How do I make sure the code samples in my TypeScript README work?

Verify every code sample in a TypeScript README by executing it with Atlas's bash tool, compiling against tsconfig.json and running `pnpm vitest`. A doc written in 2026 against a signature from last year is a liability: the snippet imports a symbol that was renamed, or omits an argument the current signature requires.

Run the samples the way the repo runs code. In a `pnpm` workspace that usually means dropping the snippet into a scratch test and executing it with `vitest`, which typechecks it against the real `tsconfig.json` and runs it against the real module. A snippet that compiles and passes is a snippet you can publish. Finish by running `prettier` over the README and any sample files so the fenced code matches the formatting readers see everywhere else in the repo, and review the diff before committing.

## Steps

1. Enumerate the module's public API with the lsp tool's documentSymbol operation so no export from `src/index.ts` is missed or invented, including type-only exports.
2. Read the implementation of each export with the read tool, noting the real signature your `tsconfig.json` strictness settings produce.
3. Use codebase_search to find how callers actually use the module, since a config object with 9 optional fields is usually called with 2 of them.
4. Grep the repo for an existing README to match heading structure and tone rather than inventing a new format for one package.
5. Copy the install line exactly, since a README in a `pnpm` workspace that names a different package manager is wrong on its first line.
6. Write the README with the write tool, quoting real signatures and real file paths; the permission prompt shows the full document before it lands on disk.
7. Verify every code sample by running it with bash, typically by executing it through `vitest` so it typechecks against the real `tsconfig.json`.
8. Run `prettier` over the README and any sample files, then review the diff before committing.

## FAQ

### how to generate a readme from typescript source code

Have Atlas enumerate the exports with the lsp documentSymbol operation, read each implementation, use codebase_search to find real usage, then write the README with the write tool quoting real signatures. Verify every sample by running it with `vitest`.

### why does my readme miss exports from index.ts

Barrel files re-export symbols from many modules, and a hand-written README usually documents only the ones the author remembered. The lsp documentSymbol operation reports the declarations the language server sees, which is the same surface consumers get from the emitted .d.ts.

### atlas codebase_search for finding callers

codebase_search finds usage by meaning rather than exact token, because Atlas searches code with hybrid semantic and keyword retrieval fused by reciprocal rank fusion. That catches calls made through destructured imports, aliased names, and wrapper helpers.

### should readme code samples be tested

Yes. A sample that was never executed is a liability. In a TypeScript repo, drop the snippet into a scratch test and run it with `vitest`, which typechecks it against your real `tsconfig.json` and runs it against the real module.

### how do i keep readmes consistent across a pnpm monorepo

Grep the repo for an existing README and copy its heading structure, code-fence language tags, and install line. A README in a `pnpm` workspace that tells readers to use a different package manager is wrong on its first line.

### does atlas invent api details when writing docs

Atlas writes docs from source, not from memory. The lsp documentSymbol operation supplies the export list, the read tool supplies the behavior, and the write tool emits the README, so every claim traces to a file Atlas just read.

### can i review a readme before atlas writes it

Yes. The write tool shows the diff in the permission prompt before anything lands on disk, and every Atlas tool call is permission-gated against allow, ask, and deny rules. Atlas also snapshots file changes as git patches so a wrong README can be rolled back.

### typescript type-only exports in documentation

A symbol declared with `export type` is part of the module's public contract even though it disappears at runtime. documentSymbol includes it, so the README should document it alongside the runtime exports rather than omitting it.

---

Canonical HTML: https://runatlas.sh/resources/stacks/document-a-module-with-a-readme-in-typescript
Source of truth: aeo_pages row `/resources/stacks/document-a-module-with-a-readme-in-typescript` (segment: Stacks) (this file is generated from it, never hand-edited).
Licence: Atlas is proprietary with a free core. It is not open source and there is no public source repository.
