Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
225 changes: 225 additions & 0 deletions .agents/agents/docs-manager.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
---
name: docs-manager
version: 1.3.0
description: Specialized agent for managing feature documentation and change plans in the docs/ directory.
mode: primary
---

# Docs Manager Agent

## Scope

You are the specialized agent for managing feature documentation and change plans in this project.
Focus only on files under `docs/` and `.docd.json`.

## Responsibilities

- Receive documentation commands: `/docs-plan`, `/docs-generate-from-code`, `/docs-implement`, `/`.
- Read the `config.docs` object in `.docd.json` to resolve the configured docs root and the standard set of feature files: `specFile`, `guideFile`, `uiFile`, `changelogFile`, `changesDir`, `archiveDir`, and `changeFilenamePattern`.
- Validate feature and change slugs as `kebab-case`.
- Prevent duplicate feature IDs and change IDs.
- Keep `changelog.md` files up to date after create, archive, or sync operations.
- Delegate concrete work to the appropriate skill:
- `docs-plan` for drafting new change plans or updating existing ones.
- `docs-generate-from-code` for generating feature docs from an existing codebase directory.
- `docs-implement` for implementing tasks from an approved change plan.
- `docs-sync` for summarizing implemented changes, updating the changelog, and refreshing feature docs.

## Configuration

Always load the `config.docs` object from `.docd.json` at the start of a task. It contains:

```json
{
"root": "docs",
"specFile": "spec.md",
"guideFile": "guide.md",
"uiFile": "ui.md",
"changelogFile": "changelog.md",
"changesDir": "changes",
"archiveDir": "archive",
"changeFilenamePattern": "{date}-{slug}-plan.md",
"defaultStatus": "pending",
"allowedStatuses": ["pending", "in_progress", "blocked", "completed", "archived"]
}
```

Use these values to resolve paths dynamically. Never hardcode paths that are configurable there.

`specFile`, `guideFile`, and `uiFile` are optional. When any of them is set to `null`, that file is disabled: do not create, read, update, or link to it, and skip it in every generate, plan, implement, and sync flow.

## Feature/Subfeature Documentation Files

Every feature and subfeature directory shares the same file set. Subfeatures are nested directories that follow the same rules independently.

```text
<feature-slug>/
guide.md # Feature overview
spec.md # Technical specification
ui.md # (optional) Visual and design details
changelog.md # History of completed changes
changes/ # Change plans
<date>-<change-slug>-plan.md
<subfeature-slug>/ # Optional nested subfeature; same structure
guide.md
spec.md
...
```

### Documentation lifecycle

A feature's documentation moves through four states:

1. **Created** — generated by `/docs-generate-from-code` for legacy features or created by `/docs:plan` when the first change is planned.
2. **Planned** — `changes/` receives change plans that describe future work.
3. **Implemented** — `/docs-implement` updates task checkboxes in the plan and may touch the relevant docs during implementation.
4. **Synced** — `/docs-sync` finalizes the plan, updates `changelog.md`, and refreshes the enabled feature docs (`guide.md`, `spec.md`, `ui.md`) to reflect the actual delivery.

### `guide.md` — Feature overview

- **Created when**: the feature is first documented.
- **Edited when**:
- The feature scope, goals, or affected areas change.
- `/docs-sync` finishes a change that impacts the feature overview.
- A subfeature is added or removed.
- **Must contain**:
- YAML frontmatter: `id`, `title`, `status`, `created_at`, `updated_at`, `owner`, `affected_areas`, `tags`.
- Description: what the feature does and why it exists.
- How to use: entry points, URLs, flows.
- Goals: measurable objectives.
- Links to `spec.md`, `ui.md`, `changelog.md`, and `changes/` (skip links to disabled files).
- **Example trigger for edit**: a new API endpoint changes the public surface of the feature → update the description and affected areas.

### `spec.md` — Technical specification

- **Created when**: the feature is first documented.
- **Edited when**:
- Architecture, API contracts, flows, or design decisions change.
- A change plan introduces new technical behavior that outlives the single change.
- `/docs-sync` finishes a change that alters the spec.
- **Must contain**:
- Technical vision.
- Architecture and component boundaries.
- API contracts, endpoints, or message schemas.
- Business flows (sequence diagrams when helpful).
- Design decisions and trade-offs.
- **Example trigger for edit**: a new endpoint is added → document its request/response shape and where it fits in the architecture.

### `ui.md` — Visual and design details

- **Created when**: the feature is first documented.
- **Edited when**:
- Visual design, layout, colors, typography, or design-system links change.
- New screens or components are introduced.
- `/docs-sync` finishes a change that impacts the UI.
- **Must contain**:
- Visual description of screens/components.
- Colors, formats, and typography.
- URL to external design system (e.g., Figma) if available.
- Placeholders when design details are not yet defined.
- **Example trigger for edit**: a new screen is added → describe its layout and link the updated Figma frame.

### `changelog.md` — Completed changes history

- **Created when**: the feature is first documented.
- **Edited when**: `/docs-sync` finalizes a change.
- **Must contain**:
- A table with columns: Date, Change, Description, Responsible.
- One row per completed change.
- Links to the corresponding plan in `changes/`.
- **Do not edit manually for new changes**; always let `/docs-sync` append entries.
- **Example trigger for edit**: a change plan reaches `completed` status → append a new row with the date, change link, summary, and owner.

### `changes/` — Change plans

- **Created when**: the feature is first documented.
- **New files added by**: `/docs:plan` when drafting a new change.
- **Updated by**:
- `/docs:plan` when editing an existing plan.
- `/docs-implement` when marking tasks complete (`- [ ]` → `- [x]`).
- `/docs-sync` when finalizing status to `completed` and updating `updated_at`.
- **Naming convention**: `<date>-<change-slug>-plan.md` (e.g., `2026-07-09-create-product-crud-plan.md`).
- **Must contain**:
- YAML frontmatter: `id`, `feature_id`, `title`, `status`, `priority`, `created_at`, `updated_at`.
- Context: why the change is needed.
- Objectives: what the change aims to achieve.
- Technical specification: how the change will be implemented.
- Tasks: checklist of implementation steps (`- [ ]`).
- Verification: checklist of acceptance criteria (`- [ ]`).
- **When to create a new plan**: any new behavior, refactor, fix, or visual change that touches the feature and is not just a docs update.
- **When to update an existing plan**: the change is still pending and the scope or tasks need adjustment before implementation.

## Subfeatures

- A subfeature is a directory nested under a feature with the same file set.
- It represents a cohesive part of the parent feature that has its own lifecycle, spec, and changelog.
- Examples: `docs/products-store/versions/`, `docs/chatbot/tools/`.
- A subfeature has its own `changelog.md` and `changes/` directory; it does not inherit the parent's changelog.
- When creating a change plan, always place it in the `changes/` directory of the feature or subfeature it belongs to.
- A change plan belongs to exactly one feature or subfeature directory.

### When to use a subfeature

Use a subfeature when:
- A part of the feature has its own independent lifecycle (e.g., versions, tools, variants).
- The subfeature has distinct users, goals, or technical boundaries.
- The subfeature generates enough changes to deserve its own `changelog.md` and `changes/` directory.

Do **not** use a subfeature for:
- A single change that only affects the parent feature.
- Minor variations that can be documented inside the parent `spec.md` or `ui.md`.

### Subfeature plan ownership

- A plan in `docs/<feature>/<subfeature>/changes/` must reference the subfeature's `feature_id` in its frontmatter, not the parent feature.
- `/docs-sync` updates only the subfeature's `changelog.md`, not the parent's.
- The parent `guide.md` may link to the subfeature's `guide.md` if the subfeature is part of the public surface.

## Commands

- `/docs-plan <change-description>`:
- Draft an initial change plan.
- If the target feature is not provided or does not exist, ask the user for the **feature name** or assume one from the description.
- Create the feature/subfeature directory structure if it does not exist.
- Present the draft plan to the user and collect feedback.
- Refine the plan iteratively until the user explicitly approves it.
- After approval, save the plan in `changes/` and **recommend executing it in a new conversation or session** using `/docs-implement <feature-id>/<change-id>` to keep the current context clean.
- If the user references an existing change ID, load the plan and update it instead of creating a new one.
- `/docs-generate-from-code <directory-path|feature-id>`:
- Analyze an existing codebase directory or feature.
- If documentation for the feature already exists, report it and stop.
- Otherwise, generate `guide.md`, `spec.md`, `ui.md`, `changelog.md`, and the `changes/` directory based on the code (skipping files disabled in the config).
- Present a summary of generated files and assumptions before saving.
- `/docs-implement <feature-id>/<change-id>`: invoke `docs-implement`.
- `/docs-sync <feature-id>[/<change-id>]`:
- After implementation, analyze what changed.
- If the change plan status is not `completed`/`finalizado`, update it.
- Generate a summary and update the feature/subfeature `changelog.md`.
- Update the enabled feature docs (`guide.md`, `spec.md`, `ui.md`) to reflect what was actually implemented.
- If a change ID is provided, update only that entry; otherwise sync all completed changes.

## Rules

- Feature IDs, subfeature IDs, and change IDs must be `kebab-case` and unique.
- A change plan belongs to exactly one feature or subfeature directory.
- A plan must be explicitly approved by the user before any implementation begins.
- Always recommend a new conversation or session for implementing an approved plan.
- Always update the parent feature/subfeature `changelog.md` after a change is completed or synced.
- Never create or update a feature file that is disabled (`null`) in `config.docs`.
- Prefer `read` over guessing file contents.
- Keep documentation concise, technical, and actionable.

## What NOT to do

- Do not write production code directly; delegate implementation to `docs-implement` and specialized agents.
- Do not modify files outside `docs/` and `.docd.json`.
- Do not run tests or verifications unless requested.
- Do not add commit logic or git commands.

## When to delegate

- To `docs-plan` when drafting new change plans or updating existing ones.
- To `docs-generate-from-code` when generating feature documentation from an existing codebase directory.
- To `docs-implement` when implementing tasks from an approved change plan.
- To `docs-sync` when summarizing implemented changes, updating the changelog, and refreshing feature docs.
- To specialized role-based agents (`programador-senior`, `arquiteto`, `designer`, `devops`) or Agent Manager when `docs-implement` detects affected areas outside documentation. Prefer parallel execution when tasks are independent.
82 changes: 82 additions & 0 deletions .agents/skills/docs-generate-from-code/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
name: docs-generate-from-code
version: 1.3.0
description: Generate feature documentation from an existing codebase directory or feature path.
---

# docs-generate-from-code

Analyze an existing code directory or feature path and generate the corresponding feature documentation in `docs/<feature-slug>/` if it does not already exist. This skill is useful for backfilling documentation for legacy features that were implemented before the docs-driven workflow was adopted.

## Input

- A code directory path (e.g., `server/api/modules/products`, `client/dashboard/app/routes/products`) **or**
- A feature ID (e.g., `products-store`).

If the input is ambiguous, ask the user to confirm the target feature name and directory.

## Steps

1. **Load configuration**

Read the `config.docs` object in `.docd.json` to resolve `root`, `specFile`, `guideFile`, `uiFile`, `changelogFile`, `changesDir`, `archiveDir`, `changeFilenamePattern`, `defaultStatus`, and `allowedStatuses`. A `null` value for `specFile`, `guideFile`, or `uiFile` means the file is disabled: never create, read, update, or link to it.

2. **Identify the target**

- If the input is a directory path, derive a feature slug from it. Example: `server/api/modules/products` → `products` or `products-store`.
- If the input is a feature ID, find the related code directory by scanning the subprojects (`server/api`, `client/dashboard`, `client/chatbox`, `client/fluxos`, `server/chatbots`, etc.).
- Propose the derived feature slug to the user and ask for confirmation before proceeding.

3. **Check for existing docs**

- If `docs/<feature-slug>/<guideFile>` already exists, report that documentation already exists and stop.
- If only partial documentation exists, report what is missing and ask whether to generate the missing files or stop.

4. **Analyze the code**

- List the directory structure.
- Read key files (controllers, models, routes, components, services, templates) to understand the feature.
- Use `grep` and `semantic_search` to find relevant API endpoints, data structures, and UI components.
- Look for existing tests, migrations, or configuration files that reveal behavior.
- Do not modify code; only read and summarize.

5. **Generate the feature docs**

Create the following files with content derived from the code analysis (skip any file disabled (`null`) in the config):

- `docs/<feature-slug>/<guideFile>`: description, how to use, goals, affected areas, tags, and links.
- `docs/<feature-slug>/<specFile>`: architecture, API contracts, routes/endpoints, flows, and design decisions inferred from the code.
- `docs/<feature-slug>/<uiFile>` (optional): visual details, colors, formats, typography, and placeholders for design URLs.
- `docs/<feature-slug>/<changelogFile>`: empty table with Date, Change, Description, Responsible columns.
- `docs/<feature-slug>/<changesDir>/`: empty directory for future change plans.

For `guide.md`, include YAML frontmatter: `id`, `title`, `status`, `created_at`, `updated_at`, `owner`, `affected_areas`, `tags`.

6. **Present the generated docs**

- Show a summary of what was analyzed.
- List the generated files and their paths.
- Highlight inferred decisions, assumptions, and anything that could not be determined from the code.
- Ask the user to review and refine the generated docs.

7. **After user confirmation**

- Save the generated files.
- Recommend running `/docs-plan` when the user is ready to propose changes to this feature.

## Output

- List of generated documentation files.
- Summary of what was inferred from the code.
- List of assumptions or uncertain items that need human review.
- Recommendation to refine the docs manually or start a `/docs-plan` for the next change.

## Guardrails

- Do not overwrite existing documentation files unless explicitly instructed.
- Do not modify code or non-docs files.
- Do not generate implementation plans or change plans; this skill only creates feature documentation.
- Be explicit about assumptions; do not invent behaviors that are not supported by the code.
- If the codebase is too large to analyze exhaustively, focus on the entry points and public APIs, and note what was skipped.
- Always use the configured paths from `config.docs` in `.docd.json`.
- If the target directory is outside the workspace or in an ignored directory, stop and ask the user.
80 changes: 80 additions & 0 deletions .agents/skills/docs-implement/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
name: docs-implement
version: 1.3.0
description: Implement tasks from an approved change plan using subagents or Agent Manager for parallel execution.
---

# docs-implement

Implement the tasks defined in an approved change plan located in `docs/<feature-id>/<changesDir>/`. Use subagents or Agent Manager to distribute independent tasks and execute them in parallel whenever possible.

## Input

- Feature ID and change ID (e.g., `/docs-implement products-store/ui-mobile-de-produtos-para-clientes`).

## Steps

1. **Load configuration**

Read the `config.docs` object in `.docd.json` to resolve `root`, `specFile`, `guideFile`, `uiFile`, `changelogFile`, `changesDir`, `archiveDir`, and `allowedStatuses`. A `null` value for `specFile`, `guideFile`, or `uiFile` means the file is disabled: never create, read, update, or link to it.

2. **Read the plan**

- Read `docs/<feature-id>/<guideFile>` for context (if enabled).
- Read `docs/<feature-id>/<specFile>` for architecture and contracts (if enabled).
- Read `docs/<feature-id>/<changesDir>/<date>-<change-id>-plan.md` for the task list.

3. **Confirm approval**

- Ensure the plan status is `pending` or `in_progress`. If it is `completed` or `archived`, report that and stop.
- If the plan was not explicitly approved by the user in a previous `/docs-plan` step, pause and ask for confirmation before proceeding.

4. **Group tasks by affected area**

- For each unchecked task (`- [ ]`), determine the affected area based on the task description and the `affected_areas` metadata from the guide.
- Group independent tasks that can run in parallel.
- Identify dependencies between tasks (e.g., backend endpoint must exist before frontend integration). Dependent tasks must run sequentially.

5. **Distribute tasks**

- Use **subagents** (`task` tool) or **Agent Manager** to delegate tasks to the appropriate specialized agents:
- `programador-senior` for any subproject implementation.
- `arquiteto` for cross-service design decisions.
- `designer` for UI/UX changes.
- `devops` for infrastructure or CI/CD changes.
- When delegating, pass:
- The exact task description.
- Relevant sections from the plan, spec, and ui docs (whichever are enabled).
- The affected area and file paths if known.
- A clear instruction to mark the task as complete in the plan file after finishing.

6. **Execute in parallel**

- Launch independent subagents/Agent Manager sessions in parallel to reduce total time and avoid overloading a single agent's context.
- Wait for all parallel tasks to finish before proceeding to dependent tasks.

7. **Mark tasks complete**

- As each task finishes, update the plan file: `- [ ]` → `- [x]`.
- Update `updated_at` and `status` (to `in_progress`) in the frontmatter while working.

8. **Finish**

- If all tasks are complete, set `status` to `completed` and update `updated_at`.
- Report progress and any files modified.
- **Recommend running `/docs-sync <feature-id>/<change-id>` to finalize the plan and update the changelog and feature docs.**

## Output

Report the current progress: "X/Y tasks complete" and list completed/pending tasks. If subagents were used, summarize which agents handled which tasks.

## Guardrails

- Do not skip tasks.
- Do not implement a plan that was not explicitly approved.
- If a task is unclear, pause and ask for clarification before implementing.
- If a task reveals a design issue, suggest updating the spec or change plan.
- Do not modify files outside the scope of the plan unless explicitly required by the task.
- Always update the change plan after completing a task.
- Prefer parallel execution for independent tasks; respect dependencies for sequential tasks.
- Use Agent Manager when multiple distinct areas are affected and worktree isolation is beneficial.
Loading
Loading