Shared Coding Contract
- Refer to Shared Coding Workflow Contract in
../lcs-shared/contract.mdfor folder conventions, Handoff format, and token optimization.
Purpose
- Consolidate completed work into high-quality documentation.
- Save documentation under
.lcs/docs/{timestamp}-{slug-work-item}/as two separate files:map.md(adapted fromaido-mapcontext map structure)doc.md(adapted fromaix-doc-finalizerfinal-doc structure)
Trigger
- Activate when the user requests to "finalize documentation", "prepare final-doc", "lcs-doc-finalizer", "selesaikan dokumentasi", or similar.
OKF Frontmatter & Writing Safety
- When creating
doc.mdandmap.md, include YAML frontmatter following the schema in../lcs-shared/contract.mdwithartifact_type: final_doc(the canonical finalization artifact is thedoc.md+map.mdpair under.lcs/docs/{timestamp}-{slug-work-item}/). - Follow the Artifact Writing Safety rules in contract.md — generate content first, write one file, verify, stop on failure.
Trigger
Activate when user requests related to this skill's purpose. See description field in YAML frontmatter for trigger phrases.
Behavior checklist
- Read
.lcs/state.mdto identify the active work-item: resolvecurrent_workto the directory.lcs/work-items/{current_work}/. Ifcurrent_workis null, alert the user and ask them to select a work item first. - Scan the task folder
.lcs/work-items/{timestamp}-{slug-work-item}/task/and read all task files (task-###.md). - Verify all task files are marked
Status: done.- If any task is NOT done (e.g.,
pendingorblocked), alert the user, list the incomplete tasks, and ask if they wish to proceed anyway or continue executing tasks first.
- If any task is NOT done (e.g.,
- Detect artifact type of the active work item:
- If
prd-enhanced.mdorprd.mdexists in the work-item folder, this is a PRD-driven work item. Readprd-enhanced.md(fallbackprd.md),explore.md, andintent.mdif present for Objective/Context. - If no PRD exists (e.g., work item originated from
lcs-codebase-docunder.lcs/codebase/), this is a non-PRD documentation work item. Read.lcs/codebase/CHAIN-OF-TRUTH.mdand the relevant.lcs/codebase/*.mdfiles instead. Fordoc.md, derive Objective/Context from the codebase documentation itself rather than a PRD; leave PRD-specific fields empty or markN/A (codebase documentation).
- If
- Create the following directories if they do not exist:
.lcs/docs/{timestamp}-{slug-work-item}/- output target for documentation files..lcs/archive/{timestamp}-{slug-work-item}/- archive target for source artifacts.
- Generate
.lcs/docs/{timestamp}-{slug-work-item}/map.mdmapping the exact files changed or created during this work-item. - Generate
.lcs/docs/{timestamp}-{slug-work-item}/doc.mdconsolidating the functional changes, verification steps, git commit recommendations, and PR description.- Read all task files from
.lcs/work-items/{timestamp}-{slug-work-item}/task/folder. - Extract task titles and descriptions from each
task-###.mdfile. - Generate
## Task Listsection in doc.md with bullet points listing all completed tasks in clear, professional English (see template for format and example).
- Read all task files from
- Update
.lcs/state.mdwith:- Set selected phase to
finalizationusing the common synchronization rule:current_phase: finalizationwork_items[current_work].phase: finalizationwork_items[current_work].updated_at: <current-ISO-timestamp>
timestamp: <current-ISO-timestamp>last_session_note: Finalized documentation for {slug-work-item}
- Set selected phase to
- Generate or update
.lcs/docs/docs-index.md(ensure the filename is exactlydocs-index.md, notreff-index.mdor any other variant) by scanning all subdirectory items under.lcs/docs/and listing theirdoc.mdandmap.mdwith timestamps and descriptions extracted frommap.mdDescription ordoc.mdObjective in a clean table. - Archive source artifacts while preserving Chain of Truth traceability.
- Copy, do not move-and-delete. Copy the entire source folder
.lcs/work-items/{timestamp}-{slug-work-item}/to.lcs/archive/{timestamp}-{slug-work-item}/so every artifact (includingcode-review.md) remains readable from the archive. - Preserve verification artifacts in docs. After copying, also copy
code-review.md(if present) into.lcs/docs/{timestamp}-{slug-work-item}/code-review.mdso the finalization docs and the verification report stay co-located and traceable together. - Delete source only after both copies succeed. Remove the source folder
.lcs/work-items/{timestamp}-{slug-work-item}/completely ONLY after: (a) the archive copy exists, and (b)code-review.md(when present) is copied into the docs folder. If any copy fails, abort the delete and alert the user — never leave traceability broken. - Guard: Only proceed with copy and delete if both
map.mdanddoc.mdwere successfully generated in step 6 and 7. If either file is missing, abort this step and alert the user.
- Copy, do not move-and-delete. Copy the entire source folder
- Stale-State Guard and Registry Cleanup. After archiving, update
.lcs/state.md:- Remove finalized entry from registry: Delete
work_items[current_work]from the state. - Clear selection: Set
current_work: nullandcurrent_phase: idle. - Update metadata: Set
timestamp: <current-ISO-timestamp>andlast_session_note: Finalized and archived {slug-work-item}. - Preserve other entries: All other
work_itemsentries remain unchanged. Do not select another item automatically. - If
.lcs/state.mdpoints to a work-item directory that no longer exists, report it as a stale reference and offer to clean it up. - Exclusion: Never touch
.lcs/docs/self-improvements/(diagnostic history fromlcs-self-improvement). It is outside the work-item archive scope and must remain intact.
- Remove finalized entry from registry: Delete
- End with a Handoff section.
Prompt templates
- Starter: "Selesaikan dokumentasi untuk "
- Explicit override: "Selesaikan dokumentasi meskipun ada task yang belum selesai"
Output Template: map.md
This file indexes the codebase area impacted by this work-item to reduce future token usage. It must be written in English.
# Map: {slug-work-item}
## Description
<One-line area summary of what this module/feature does>
## Files Impacted
This section lists only existing files that were modified or created for this work-item.
* **Modified files**:
- `path/to/modified-file-1.ext`
- `path/to/modified-file-2.ext`
* **Created files**:
- `path/to/created-file-1.ext`
## Rationale
* `<file-path>`: <One-line reason why this file was modified or created>
* `<file-path>`: <One-line reason why this file was modified or created>
## System Relations
<One-line explanation of how this feature/module interacts with other parts of the system, e.g., database, auth, UI>
Output Template: doc.md
This file acts as the canonical feature specification and PR summary. It must be written in English.
# Documentation: {slug-work-item}
## Objective
<Direct summary of goals achieved by this work-item>
## Context & Background
<Why this work-item was implemented, linking back to original explore.md or prd.md findings>
## Functional Changes
<Bullet list of user-facing or programmatic changes introduced>
## Verification & Test Results
<List of tests executed, test commands run, and results confirming success>
## Recommended Git Commit
```text
{type}(<scope>): <short description>
- <bullet points detailing change 1>
- <bullet points detailing change 2>
Recommended PR Description
### Summary
<High-level summary of the changes>
### Key Changes
- **Feature A**: <detail>
- **Refactoring**: <detail>
### How to Test
1. Run `<test command>`
2. Verify `<expected outcome>`
Task List
Read all task files from .lcs/work-items/{timestamp}-{slug-work-item}/task/ folder and list completed tasks in concise, clear English using natural, professional language that sounds human and semi-formal, without being overly technical. Use bullet point format.
Example:
- Implemented user authentication with JWT tokens
- Created database migration for user profiles table
- Added input validation for registration form
Chain of Truth Report
Level
Strict
Sources Checked
.lcs/state.md.lcs/work-items/{timestamp}-{slug-work-item}/task/task-*.md.lcs/work-items/{timestamp}-{slug-work-item}/prd-enhanced.md.lcs/work-items/{timestamp}-{slug-work-item}/code-review.md(if present)
Assumptions
- <label each [verified] or [unverified]>
Plan
Actions Taken
Verification
<Automated checks attempted; document every failure>
Report
<Explicit pass/fail per acceptance criterion>
Handoff
Next recommended skill: none (workflow complete) Next file to read: .lcs/docs/{timestamp}-{slug-work-item}/doc.md Current phase: complete Current confidence: high Blocking questions: None Risks to carry forward: None Source of Truth Bundle: .lcs/state.md, explore.md if present, intent.md if present, prd-enhanced.md if present, prd.md, srs.md if present, tests.md if present, task-coverage.md if present, traceability.md if present, code-review.md if present Must Preserve IDs: <SRC/FR/AC/TEST IDs covered by finalized work> Unresolved IDs: Suggested next command: Buat PR dengan pesan yang direkomendasikan
---
## Output Template: docs-index.md
This file contains the table of contents of all generated documentation references. It is a navigation artifact and MUST carry OKF frontmatter with `artifact_type: index` so whole-directory scans (e.g. `validate-okf.py .lcs/docs/`) pass.
```markdown
---
title: "Documentation References Index"
format_version: "okf/0.2"
authors:
- type: agent
name: "lcs-doc-finalizer"
created: "{YYYY-MM-DD}"
updated: "{YYYY-MM-DD}"
tags: [index, docs]
summary: "Table of contents of all finalized documentation"
status: active
related: []
artifact_type: index
source: ".lcs/docs/"
cot_level: strict
version: "1.0"
---
# Documentation References Index
| Timestamp | Work Item | Description | Map | Documentation |
|-----------|-----------|-------------|-----|---------------|
| {timestamp} | {slug-work-item} | {one-line summary extracted from map.md Description} | [Map](./{timestamp}-{slug-work-item}/map.md) | [Doc](./{timestamp}-{slug-work-item}/doc.md) |
Chain of Truth Level
Level: Strict
This skill follows the LCS Chain of Truth protocol at the declared level.