Map existing repositories into evidence-based docs for onboarding, architecture discovery, technical review, and long-term maintainability.
Mode selection (required before execution)
Before any scan or documentation step, ask user to choose exactly one mode by number only:
Quick Update- Focus on latest changes and update only impacted sections in existing docs.
Standard Refresh- Run full scoped scan and refresh all existing docs in place.
Rebuild Docs- Recreate content for all seven docs from scratch in
.lcs/codebase/.
- Recreate content for all seven docs from scratch in
Rules:
- Do not start Phase 1 before user selects
1,2, or3. - Accept numeric input only.
- If input is invalid, ask one more time with the same three options.
- After valid input, print
Selected mode: <name>and continue. - If docs already exist in
.lcs/codebase/, never overwrite full files in mode1or mode2; update sections in place. - Full-file regeneration is allowed only in mode
3.
OKF Frontmatter & Writing Safety
- When creating codebase documentation files (
.lcs/codebase/*.md), include YAML frontmatter following the schema in../lcs-shared/contract.mdwithartifact_type: codebase_doc. - Follow the Artifact Writing Safety rules in contract.md — generate content first, write one file, verify, stop on failure.
Output contract
Before finishing, ensure exactly these files exist under .lcs/codebase/:
.lcs/codebase/STACK.md.lcs/codebase/STRUCTURE.md.lcs/codebase/ARCHITECTURE.md.lcs/codebase/CONVENTIONS.md.lcs/codebase/INTEGRATIONS.md.lcs/codebase/TESTING.md.lcs/codebase/CONCERNS.md.lcs/codebase/CHAIN-OF-TRUTH.md(Chain of Truth Report — written in Phase 4)
Rules for every doc:
- Base claims only on verifiable evidence from source files, manifests, configs, docs, git history, or terminal output.
- Add an
Evidencesection with concrete file paths. - Use
[TODO]when evidence is missing. - Use
[ASK USER]for product/team intent, ownership, or decisions requiring human clarification. - Separate stated intent from actual implementation.
- Never guess or invent architecture.
Workflow checklist
- Mode selection: Ask and confirm
1|2|3, then print selected mode - Phase 1: Create
.lcs/codebase/, run scan, read intent documents from.lcs/docs/ - Phase 2: Investigate each documentation area
- Phase 3: Populate all seven docs in
.lcs/codebase/ - Phase 4: Validate docs, repair unsupported claims, write
.lcs/codebase/CHAIN-OF-TRUTH.md, present findings
Phase 1: Scan and read intent
- Create output directory using host shell.
- Unix-like example:
mkdir -p .lcs/codebase - PowerShell example:
New-Item -ItemType Directory -Force -Path ".lcs/codebase"
- Unix-like example:
- Run bundled scan script from target project root.
- Unix-like example:
python3 "$SKILL_ROOT/scripts/scan.py" --output .lcs/codebase/.codebase-scan.txt - PowerShell example:
python "$SKILL_ROOT/scripts/scan.py" --output .lcs/codebase/.codebase-scan.txt - If
pythonis unavailable on Windows, use:py -3 "$SKILL_ROOT/scripts/scan.py" --output .lcs/codebase/.codebase-scan.txt $SKILL_ROOTis absolute path toskills/lcs-codebase-doc.
- Unix-like example:
- Read intent docs in
.lcs/docs/before deep source inspection. - Prioritize files and content signals: README, PRD, TRD, ROADMAP, SPEC, DESIGN, ARCHITECTURE, CONTRIBUTING, ADR, planning notes, product requirements, technical requirements, implementation plans, decision records.
- If
.lcs/docs/missing or no relevant docs, mark[TODO]or[ASK USER]where needed. - Summarize stated intent separately from observed implementation.
Phase 2: Investigate
Use .lcs/codebase/.codebase-scan.txt and direct inspection.
Scope rules for investigation:
-
Inspect project source, configs, and manifests only.
-
Ignore hidden directories (
.*) except.lcs. -
Within
.lcs, read only.lcs/docs/as intent source. -
Root dot-files are allowed (for example
.env.example,.gitlab-ci.yml). -
Do not inspect
.github/. -
Do not inspect
skills/,vendor/, or generated/dependency/build/cache folders. -
Primary questions and validations:
references/inquiry-checkpoints.md -
Ambiguous stack detection:
references/stack-detection.md
Cover at least:
- Language/runtime detection
- Package manager detection
- Dependency classification (production vs development)
- Entry points and directory structure
- Architecture/module boundaries and conventions
- Integrations and environment configuration
- Testing setup and CI/CD
- Containerization and orchestration
- Security/compliance tooling
- Performance/benchmark markers
- TODO/FIXME/HACK markers
- High-churn files from git history (if available)
Phase 3: Populate templates
Copy templates from assets/templates/ to .lcs/codebase/ and complete in order:
STACK.mdSTRUCTURE.mdARCHITECTURE.mdCONVENTIONS.mdINTEGRATIONS.mdTESTING.mdCONCERNS.md
Phase 4: Validate and report
Before final response:
- Validate each doc using
references/inquiry-checkpoints.md. - Ensure every non-trivial claim has evidence.
- Replace unsupported claims with
[TODO]or remove them. - Collect
[ASK USER]items as numbered questions. - Highlight intent-vs-implementation divergence.
- Summarize outputs created under
.lcs/codebase/. - Clearly report limitations, missing evidence, missing
.lcs/docs/, or scan failures. - Write
.lcs/codebase/CHAIN-OF-TRUTH.mdwith the Chain of Truth Report (Level: Strict) covering sources checked, assumptions, actions taken, verification results, and confidence rating.
Focus-area mode
If user asks for a subset (for example: architecture only, testing and concerns, stack and integrations, security concerns only):
- Always run Phase 1 fully.
- Complete requested focus docs first.
- Still create all seven docs under
.lcs/codebase/. - For non-focus docs, keep sections and mark unresolved parts as
[TODO]. - Run full Phase 4 validation across all seven docs.
Gotchas and anti-patterns
- For monorepos, inspect workspaces/packages/apps/services and package-level manifests.
- Do not assume root manifest represents full repo.
- Treat
.lcs/docs/as primary intent source, but verify all implementation claims from real files. - Do not trust docs claims without source/config/manifest confirmation.
- Do not infer databases from env variable names alone.
- Do not document generated output folders as source conventions.
- Map TypeScript path aliases from
tsconfig.jsonto actual directories. - Distinguish production dependencies from dev dependencies.
- Treat TODOs in tests as testing gaps, not production debt.
- Use git history for churn signals when available.
- Never expose secrets; document variable names only from
.env.example,.env.sample,.env.template, or equivalents. - If repo too large, prioritize manifests, entry points, core source dirs, test setup, CI/CD, and integration boundaries.
- If CI/security evidence lives only under skipped hidden directories (for example
.github/), mark related items as[TODO].
Chain of Truth Report
Level
Strict
Sources Checked
- Project source files, configs, and manifests
- Intent documents from
.lcs/docs/ .codebase-scan.txtscan output- Git history (if available)
references/inquiry-checkpoints.mdandreferences/stack-detection.md
Assumptions
- User selected a valid mode (1, 2, or 3) before execution
.lcs/codebase/is the canonical output directory- Hidden directories (except
.lcs) do not contain project source
Plan
- Phase 1: Create
.lcs/codebase/, run scan, read intent docs - Phase 2: Investigate each documentation area
- Phase 3: Populate all seven docs in
.lcs/codebase/ - Phase 4: Validate docs, repair unsupported claims, write CHAIN-OF-TRUTH.md
Actions Taken
- Ran mode selection with user
- Executed scan via bundled
scripts/scan.py - Read intent documents from
.lcs/docs/ - Investigated codebase areas (stack, structure, architecture, conventions, integrations, testing, concerns)
- Populated templates from
assets/templates/ - Validated claims against evidence from source files
- Wrote
.lcs/codebase/CHAIN-OF-TRUTH.md
Verification
- Each doc validated against
references/inquiry-checkpoints.md - Every non-trivial claim has evidence or
[TODO]marker [ASK USER]items collected as numbered questions- All seven output files exist under
.lcs/codebase/
Report
Confidence: Medium (varies per doc area based on evidence availability)
Limitations: Claims without source confirmation marked as [TODO]; intent-vs-implementation divergence noted where found
Handoff
Next recommended skill: lcs-doc-finalizer
Next file to read: .lcs/codebase/CHAIN-OF-TRUTH.md
Current phase: codebase_documentation
Current confidence: medium
Blocking questions: None
Risks to carry forward: Unvalidated claims marked as [TODO]; missing intent docs may reduce accuracy
Source of Truth Bundle: .lcs/state.md, .lcs/codebase/STACK.md, .lcs/codebase/STRUCTURE.md, .lcs/codebase/ARCHITECTURE.md, .lcs/codebase/CONVENTIONS.md, .lcs/codebase/INTEGRATIONS.md, .lcs/codebase/TESTING.md, .lcs/codebase/CONCERNS.md, .lcs/codebase/CHAIN-OF-TRUTH.md
Must Preserve IDs: None
Unresolved IDs: None
Suggested next command: Finalize codebase documentation
Chain of Truth Level
Level: Strict
This skill follows the LCS Chain of Truth protocol at the declared level.