- Home
- Skills
- Technical Documentation
- Documenting Features — Living DDD Docs in One File
Works with the AI Agents you already use
Documenting Features — Living DDD Docs in One File
Turns an implemented feature into one living Markdown doc: glossary, domain model, Gherkin, ADRs, specs, C4 diagrams.
Free
Documenting Features — Living DDD Docs in One File
Example session with this skill installed
Document the workspace invitations feature we just shipped (PR #212: "Admins can invite people by email; links expire after 7 days. We store only a SHA-256 hash of the token so a DB leak can't be used to join workspaces."). Routes: POST /workspaces/{workspace_id}/invitations → 201 {id, email, role, expires_at}; POST /invitations/accept with {token} → 200 {member_id, workspace_id, role}. Errors map PermissionDenied→403, Conflict→409, NotFound→404, Gone→410. Migration 0031_create_invitations.py has a downgrade. Rollout flag workspace_invitations (default off). Role is ADMIN | MEMBER | VIEWER.
# app/invitations/service.py
INVITE_TTL = timedelta(days=7)
class InvitationService:
def invite(self, actor: Member, email: str, role: Role) -> Invitation:
if actor.role is not Role.ADMIN:
raise PermissionDenied("INVITE_FORBIDDEN")
if self.members.exists(actor.workspace_id, email.lower()):
raise Conflict("ALREADY_MEMBER")
token = secrets.token_urlsafe(32)
inv = Invitation(workspace_id=actor.workspace_id, email=email.lower(), role=role,
token_hash=sha256_hex(token), expires_at=utcnow() + INVITE_TTL)
self.repo.add(inv)
self.mailer.send_invite(inv.email, token)
self.events.publish(InvitationSent(inv.id, inv.workspace_id, inv.email))
metrics.incr("invitations.sent")
log.info("invitation.sent", invitation_id=inv.id, workspace_id=inv.workspace_id)
return inv
def accept(self, token: str, user: User) -> Member:
inv = self.repo.by_token_hash(sha256_hex(token))
if inv is None or inv.accepted_at is not None:
raise NotFound("INVITE_INVALID")
if inv.expires_at < utcnow():
raise Gone("INVITE_EXPIRED")
if user.email.lower() != inv.email:
raise PermissionDenied("INVITE_EMAIL_MISMATCH")
member = self.members.add(inv.workspace_id, user.id, inv.role)
inv.accepted_at = utcnow()
self.events.publish(InvitationAccepted(inv.id, member.id))
metrics.incr("invitations.accepted")
return member
- Read your context and instructions
- Compiled the documenting features
Here is the feature doc for Workspace Invitations, ready to save as docs/features/workspace-invitations.md. Everything comes from the code, routes and PR you gave me. The 8 items the code doesn't show are marked TBD and listed at the end. I haven't saved or committed anything.
# Feature: Workspace Invitations
> Generated on: 2026-10-08
> Status: Draft
> Owner: TBD
---
## 1. Overview
### Summary
Workspace admins invite people by email to join a workspace with a given role. The invitee
accepts through a single-use link that expires after 7 days and only works for the invited
email address.
### Business Context
Teams need a self-serve way to grow a workspace without manual account provisioning, without
letting a leaked database row or a forwarded link grant access to the wrong person.
### Bounded Context
Workspace Membership.
### Related Contexts
- Identity (`User`): Customer-Supplier. Invitations consume the authenticated user's email.
- Notifications (mailer): Customer-Supplier. Delivers the invite link.
- Event consumers of `InvitationSent` / `InvitationAccepted`: TBD.
---
## 2. Ubiquitous Language Glossary
| Term | Definition | Code Reference |
|------|------------|----------------|
| Invitation | A pending offer for an email address to join a workspace with a role | `Invitation`, `invitations` table |
| Invite | The act of an admin creating an invitation | `InvitationService.invite` |
| Accept | Redeeming an invitation, which creates a membership | `InvitationService.accept` |
| Member | A user's membership in a workspace, with a role | `Member`, `members.add` |
| Role | Access level granted in a workspace: ADMIN, MEMBER, VIEWER | `Role` |
| Invitation token | Secret sent by email; only its SHA-256 hash is stored | `token`, `token_hash`, `sha256_hex` |
| Invitation TTL | How long an invitation stays valid: 7 days | `INVITE_TTL` |
---
## 3. Domain Model
### 3.1 Aggregates
#### Invitation
- **Root Entity:** `Invitation`
- **Value Objects:** `Role`
- **Invariants:**
- Only an ADMIN can create an invitation (`INVITE_FORBIDDEN`).
- An invitation is never created for an email that is already a member (`ALREADY_MEMBER`).
- Emails are stored and compared in lowercase.
- The raw token is never persisted; only `token_hash`.
- An invitation can be accepted at most once (`accepted_at` set → `INVITE_INVALID`).
- An invitation cannot be accepted after `expires_at` (`INVITE_EXPIRED`).
- Only the user whose email matches can accept (`INVITE_EMAIL_MISMATCH`).
### 3.2 Domain Events
| Event | Trigger | Payload | Consumers |
|-------|---------|---------|-----------|
| `InvitationSent` | Invitation created and email handed to the mailer | invitation id, workspace id, email | TBD |
| `InvitationAccepted` | Invitee accepted; membership created | invitation id, member id | TBD |
---
## 4. Behavior Specifications
### Feature: Invite people to a workspace
**As a** workspace admin
**I want** to invite someone by email with a role
**So that** they can join my workspace without manual provisioning
### Background
- Given a workspace "Acme" whose admin is "ada@acme.com"
### Scenario: Admin invites a new person
- **Given** "bob@acme.com" is not a member of "Acme"
- **When** the admin invites "Bob@Acme.com" as MEMBER
- **Then** an invitation for "bob@acme.com" with role MEMBER is created, expiring in 7 days
- **And** an invite email is sent to "bob@acme.com"
### Scenario: Invitee accepts a valid invitation
- **Given** a pending invitation for "bob@acme.com" as MEMBER
- **When** "bob@acme.com" accepts it with the emailed token
- **Then** Bob becomes a MEMBER of "Acme"
### Scenario: Invitation already accepted (edge)
- **Given** an invitation that was already accepted
- **When** the token is used again
- **Then** the request is rejected with 404 `INVITE_INVALID`
### Scenario: Expired invitation (edge)
- **Given** an invitation whose 7-day window has passed
- **When** the invitee accepts it
- **Then** the request is rejected with 410 `INVITE_EXPIRED`
### Scenario: Inviting an existing member (error)
- **Given** "bob@acme.com" is already a member of "Acme"
- **When** the admin invites "bob@acme.com"
- **Then** the request is rejected with 409 `ALREADY_MEMBER`
### Scenario: Non-admin tries to invite (authorization)
- **Given** a user with role MEMBER in "Acme"
- **When** they invite "carol@acme.com"
- **Then** the request is rejected with 403 `INVITE_FORBIDDEN`
### Scenario: Wrong user accepts a forwarded link (authorization)
- **Given** a pending invitation for "bob@acme.com"
- **When** "eve@other.com" accepts it with the same token
- **Then** the request is rejected with 403 `INVITE_EMAIL_MISMATCH`
Test mapping: TBD. Each scenario should map to one test in the suite. Confirm the names.
---
## 5. Architecture Decision Records
### ADR-001: Store only a hash of the invitation token
**Status:** Accepted (PR #212)
#### Context
Invitation links grant workspace access. If raw tokens were stored, anyone with read access to
the database (a leak, a backup, an over-privileged query) could join any workspace with a
pending invite.
#### Decision
Generate the token with `secrets.token_urlsafe(32)`, send it only by email, and persist only
`sha256_hex(token)`. Acceptance looks invitations up by the hash.
#### Consequences
**Benefits:** a database leak does not yield usable invite links.
**Trade-offs:** a lost email can't be recovered by reading the token back; the admin must
re-invite. Support can't see or resend the original link.
**Impact on Product:** "resend invite" has to issue a new token.
---
## 6. Technical Specification
### 6.1 Dependencies
| Type | Name | Purpose |
|------|------|---------|
| Database | `invitations` table (migration `0031_create_invitations.py`) | Invitation state |
| Service | Mailer (`self.mailer`) | Sends the invite email with the token |
| Event bus | `self.events` | Publishes `InvitationSent`, `InvitationAccepted` |
### 6.2 API Contracts
#### POST `/workspaces/{workspace_id}/invitations`
**Request:** `{ "email": "string", "role": "ADMIN | MEMBER | VIEWER" }` (field names: TBD, confirm against the router)
**Response (201):** `{ "id", "email", "role", "expires_at" }`
#### POST `/invitations/accept`
**Request:** `{ "token": "string" }`
**Response (200):** `{ "member_id", "workspace_id", "role" }`
### 6.3 Error Handling
| Error Code | Condition | HTTP | User Message | Recovery Action |
|------------|-----------|------|--------------|-----------------|
| `INVITE_FORBIDDEN` | Actor is not ADMIN | 403 | TBD | Ask a workspace admin |
| `ALREADY_MEMBER` | Email already a member | 409 | TBD | None needed |
| `INVITE_INVALID` | Unknown token or already accepted | 404 | TBD | Ask for a new invite |
| `INVITE_EXPIRED` | Past `expires_at` | 410 | TBD | Ask for a new invite |
| `INVITE_EMAIL_MISMATCH` | Logged-in email ≠ invited email | 403 | TBD | Log in with the invited email |
---
## 7. Observability
### 7.1 Key Metrics
| Metric | Type | Description | Alert Threshold |
|--------|------|-------------|-----------------|
| `invitations.sent` | Counter | Invitations created | TBD |
| `invitations.accepted` | Counter | Invitations accepted | TBD |
### 7.2 Important Logs
| Level | Event | Fields | When |
|-------|-------|--------|------|
| INFO | `invitation.sent` | `invitation_id`, `workspace_id` | Invitation created |
No log is emitted on accept or on rejection paths.
### 7.3 Dashboards
TBD.
---
## 8. Deployment & Rollback
### 8.1 Feature Flags
| Flag | Purpose | Default | Rollout Strategy |
|------|---------|---------|------------------|
| `workspace_invitations` | Enables the invitation endpoints | off | TBD |
### 8.2 Database Migrations
- `0031_create_invitations.py`: creates `invitations`. **Reversible** (has a downgrade).
### 8.3 Rollback Plan
1. Turn `workspace_invitations` off.
2. Confirm both endpoints are no longer reachable through the flag.
3. Only if the table itself must go: run the `0031` downgrade. **Data consideration:** this
deletes pending invitations, so outstanding links stop working. Memberships already
created by accepted invites are not removed.
### 8.4 Smoke Tests (post-deploy)
- [ ] Admin invites a test address in staging; `invitation.sent` log appears.
- [ ] Accepting the emailed link creates the membership; `invitations.accepted` increments.
- [ ] Reusing the same link returns 404 `INVITE_INVALID`.
---
## 9. Architecture Diagrams
### 9.1 Context Diagram (Level 1)
```mermaid
C4Context
title System Context diagram for Workspace Invitations
Person(admin, "Workspace admin", "Invites people")
Person(invitee, "Invitee", "Accepts the invitation")
System(app, "Workspace App", "Manages workspaces and memberships")
System_Ext(mail, "Mail delivery", "Delivers invite emails")
Rel(admin, app, "Creates invitations")
Rel(app, mail, "Sends invite link")
```
Rel(invitee, app, "Accepts invitation")
```
```
Level 2 (Container): TBD. The containers (API, database engine, event bus technology)
aren't visible in the code provided, and the diagram must only show things that exist.
---
## 10. Platform Compatibility
Server-side feature with no OS-specific code in the service shown. Supported deployment
targets, image and CI matrix: TBD.
Gaps to close (flagged, not invented)
- Owner of the doc.
- Consumers of
InvitationSentandInvitationAccepted. - Request field names for
POST /workspaces/{workspace_id}/invitations. - User-facing messages for the five error codes.
- Alert thresholds and dashboards for both counters.
- Rollout strategy for
workspace_invitations. - Container diagram: API, database and event-bus technologies.
- Test mapping for the 7 Gherkin scenarios, plus deployment targets and the CI matrix for Section 10.
Observations from reading the code (not documented as behavior)
invite()saves the row before sending the email. Whether a mailer failure rolls the row back depends on transaction handling, which isn't shown. Worth confirming.- Nothing in
invite()prevents two pending invitations for the same email. If that's intended, consider an ADR. If not, it's a bug to ticket. - The accept path and all rejection paths emit no log. Ops can only see them through HTTP status codes.
Next steps
- Answer the 8 gaps (or tell me where to find them) and I'll fill in the
TBDs. - Save as
docs/features/workspace-invitations.mdand update it in the same PRs that change the feature.
Connects securely to your tools. The creator never sees your data.
About this skill
Documenting Features has your agent read the code you shipped and write one Markdown file per feature that Product can check and Engineering can maintain. The file lives next to the code at docs/features/<feature>.md and changes in the same PRs as the code.
The problems it solves
- Feature knowledge spread across PRs, tickets and people's heads
- The business, the code and the database using three different names for the same thing
- Docs that describe metrics, endpoints or diagram boxes that don't exist
- Rollback plans that no one has checked against the current code
The 10 sections: Overview · Ubiquitous Language glossary (term → definition → code symbol) · Domain Model (aggregates, invariants, domain events) · Gherkin behaviors (happy, edge, error and authorization paths) · ADRs (only for decisions the team actually debated) · Technical Spec (dependencies, API contracts, error table) · Observability (metrics, logs, alerts) · Deployment & Rollback (flags, migrations, numbered rollback, smoke tests) · C4 diagrams in Mermaid · Platform Compatibility.
Each workflow step ends with a check against the code. Every glossary term must appear in the code, every invariant needs a test or a guard, every metric must actually be emitted, and every diagram box must exist. Anything the code doesn't show is marked TBD and flagged, never made up.
What's inside
references/template.md: the complete 10-section templatereferences/gherkin.md: scenario structure, coverage rules, anti-patterns, mapping scenarios to testsreferences/c4-diagrams.md: Mermaid C4 Context, Container and Component, plus when to skip diagramsreferences/communication.md: answer-first writing (Minto Pyramid, SCQA)
When it triggers: "document this feature", "write feature docs", "create ADRs", "document the domain model", or living docs.
Docs are always written in English. By default the skill prints the doc in chat and never commits. It documents only what was asked: no extra doc files, no summary .md nobody requested, and no rewriting of docs the change didn't make inaccurate.
Free and MIT-licensed, part of the claude-skills-czl collection.
Source on GitHub: this skill · full repository
Prints the doc in chat unless you ask it to save docs/features/<feature>.md. It only documents what exists in code, tests and PRs, and never creates extra doc files or rewrites docs the change didn't make inaccurate. Never runs git.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Free to use
No account required to browse
Trust & safety
Security scan
Security scan passed 9 days ago
- Free with an Agensi account
Mac only
- Software
Git
Permissions
File Scopes
- Read files: yes. It reads production code, tests, PR descriptions and existing ADRs. - Edit files: by default it only prints the doc in chat. It writes `docs/features/<feature>.md` only when you explicitly ask it to save the file. Its hard rules forbid extra doc files and rewriting existing docs the change didn't make inaccurate. - Run shell commands: only to search the codebase and confirm that cited symbols, metrics and logs exist. It doesn't run builds or tests. - Network access: no. - Git/GitHub: explicitly forbidden. It never runs `git add`, `git commit` or `git push`. - Skill memory: it may add a `learnings/YYYY-MM-DD-slug.md` file inside its own folder for project conventions (ADR location, glossary inheritance, template variants).
What's inside
Frequently Asked Questions
New in Technical Documentation
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Technical Documentation.