skills/cali-codebase-spec/SKILL.md
[Cali] Use this skill whenever the user wants to analyze a codebase and generate a detailed product spec document. Triggers for: "analyze this codebase", "generate a spec", "document this project", "reverse engineer this app", "what does this system do", "create product documentation", "map out the features", "extract product rules from code", "what does this codebase do", "generate product spec from code", "document this app", "spec out this repo", "read this code and tell me what it does", "create a product spec", "reverse engineer the product", "what features does this app have", "document the flows", "extract the prompts from this code", or any request to extract product knowledge from source code. Supports any input method: file uploads, pasted code, filesystem paths, or zip archives. Always use this skill when the user shares code AND wants to understand what the product does — even if they don't explicitly say "spec" or "documentation".
npx skillsauth add renatocaliari/agent-sync-public-skills cali-codebase-specInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
You are a senior product analyst reverse-engineering a product from its source code. Your job: produce a living product specification that is completely tech-stack-agnostic — so thorough that another team could rebuild the product in any language or framework.
Accept codebase via any of:
find + cat to readIf the input is a zip file:
unzip -o <file> -d /tmp/cali-codebase-spec-input
find /tmp/cali-codebase-spec-input -type f | sort
# or for uploads: ls -R /mnt/user-data/uploads/
Look for: package.json, pyproject.toml, go.mod, Gemfile, pom.xml, *.csproj,
Dockerfile, docker-compose.yml, *.env.example, CI configs, README files.
Search for:
grep -r "openai\|anthropic\|claude\|gpt\|gemini\|mistral\|llama\|ollama\|langchain\|llamaindex\|huggingface\|transformers\|replicate\|groq\|cohere\|bedrock\|vertex" \
--include="*.js" --include="*.ts" --include="*.py" --include="*.go" \
--include="*.rb" --include="*.java" --include="*.cs" -l -i /tmp/cali-codebase-spec-input 2>/dev/null
Then read every file that matches to extract:
gpt-4o, claude-3-5-sonnet, gemini-1.5-pro)These reveal every feature the product has.
DB models, Zod/Pydantic schemas, GraphQL types, Prisma schema, etc.
Especially forms, modals, pages — they reveal exact fields, validations, and UX flows.
Services, hooks, utilities, middleware — where the rules live.
REST routes, GraphQL resolvers, tRPC routers, gRPC protos.
After reading everything, synthesize the full picture before writing. Ask yourself:
Output a single Markdown document with the sections below, in the same language the user wrote in (if user wrote in Portuguese, spec is in Portuguese; if English, spec is in English).
Save as /mnt/user-data/outputs/<project-name>-spec.md
# [Product Name] — Product Spec
> Reverse-engineered from source code. Tech-stack agnostic.
> Generated: [date]
## 1. Product Overview
## 2. Tech Stack Summary (context only)
## 3. User Roles & Permissions
## 4. Features & Product Rules
## 5. User Flows (with ASCII art)
## 6. Screens & Components (with ASCII art)
## 7. Data Models
## 8. API Surface
## 9. AI / LLM Integration (detailed)
## 10. Business Rules Catalog
## 11. Open Questions / Inferred Behavior
One paragraph: what is this, who uses it, what core problem it solves.
| Layer | Technology | Notes |
|--------------|-----------------|--------------------------|
| Frontend | React + Next.js | App Router |
| Backend | Node / Express | REST API |
| Database | PostgreSQL | via Prisma ORM |
| AI | OpenAI SDK | GPT-4o, streaming |
| Auth | NextAuth.js | Google + email/password |
| Infra | Vercel + Railway | |
Note: This section exists for context only. The rest of the spec is tech-agnostic.
List every role found in the code (admin, user, guest, etc.) and what each can do.
For each major feature:
### Feature: [Name]
**Description:** What it does in plain English.
**Rules:**
- Rule 1 (extracted from validation / business logic)
- Rule 2
- ...
**Edge cases handled:**
- ...
Use ASCII art to draw every major flow. Examples:
Navigation flow:
[Login] ──► [Dashboard]
│
┌─────────┼──────────┐
▼ ▼ ▼
[Projects] [Settings] [Profile]
│
▼
[Project Detail] ──► [Edit Project]
│
[Save] / [Cancel]
Decision flow:
User submits form
│
▼
[Validate input]
│
┌───┴───┐
PASS FAIL
│ │
▼ ▼
[Save] [Show errors]
│
▼
[Send confirmation email]
│
▼
[Redirect to dashboard]
Sequence / interaction flow:
User Frontend Backend AI (LLM)
│ │ │ │
│──send msg─────►│ │ │
│ │──POST /chat─►│ │
│ │ │──prompt─────►│
│ │ │◄─stream──────│
│ │◄─SSE stream──│ │
│◄─render tokens─│ │ │
Draw wireframe-level ASCII for every distinct screen. Be thorough — include labels, fields, buttons, states.
Example — Dashboard screen:
┌─────────────────────────────────────────────────────┐
│ 🏠 MyApp [Notifications 🔔] [User ▼] │
├──────────────┬──────────────────────────────────────┤
│ │ Welcome back, João! │
│ 📊 Dashboard│ │
│ 📁 Projects │ ┌──────────┐ ┌──────────┐ │
│ ⚙️ Settings │ │ 12 │ │ 3 │ │
│ 👤 Profile │ │ Projects │ │ Active │ │
│ │ └──────────┘ └──────────┘ │
│ │ │
│ │ Recent Activity │
│ │ ┌─────────────────────────────────┐ │
│ │ │ • Project X updated 2min ago │ │
│ │ │ • New comment on Y 1hr ago │ │
│ │ └─────────────────────────────────┘ │
│ │ │
│ │ [+ New Project] │
└──────────────┴──────────────────────────────────────┘
For each screen, also list:
For each entity:
### Entity: User
| Field | Type | Rules / Notes |
|---------------|-----------|----------------------------------|
| id | UUID | auto-generated |
| email | string | unique, required, validated |
| role | enum | user | admin | guest |
| created_at | timestamp | auto |
Relations:
- User has many Projects
- User has many Comments
### POST /api/auth/login
**Purpose:** Authenticate user
**Auth:** Public
**Body:** { email: string, password: string }
**Returns:** { token: string, user: User }
**Rules:**
- Rate limited: 5 attempts / 15min
- Returns 401 if credentials invalid
- Logs failed attempts
This is the most important section for AI-powered products.
### AI Feature: [Name] (e.g. "Chat Assistant", "Document Summarizer")
**Provider:** OpenAI / Anthropic / etc.
**Model:** gpt-4o / claude-3-5-sonnet-20241022 / etc.
**Endpoint:** /api/chat or similar
**Streaming:** yes/no
**System Prompt:**
\`\`\`
[exact system prompt extracted from code]
\`\`\`
**User Prompt Template:**
\`\`\`
[exact template, with {variable} placeholders shown]
\`\`\`
**Few-shot Examples (if any):**
\`\`\`
[extracted examples]
\`\`\`
**Inference Parameters:**
| Param | Value |
|---------------|--------|
| temperature | 0.7 |
| max_tokens | 2000 |
| top_p | 1.0 |
**Input:** What is passed to the model (user message, context, retrieved docs, etc.)
**Output:** What the model returns and how it's used
**Post-processing:** Any parsing, validation, or transformation applied to the response
**RAG / Context injection (if any):**
- Vector DB: Pinecone / Chroma / pgvector / etc.
- Embedding model: text-embedding-3-small / etc.
- Chunking: [strategy extracted from code]
- Top-k: [number]
- What documents are indexed
**Tool / Function calling (if any):**
\`\`\`json
[exact tool definitions extracted from code]
\`\`\`
**Error handling:**
- What happens on API failure
- Fallback behavior
- Retry logic
A numbered, exhaustive list of every rule found in the codebase:
BR-001: Users cannot delete a project with active subscriptions.
BR-002: Email must be verified before accessing paid features.
BR-003: AI features are disabled for free tier users.
BR-004: Messages are truncated to 4000 tokens before sending to LLM.
BR-005: Admin can impersonate any user account.
...
Be honest about what was inferred vs. explicitly coded:
⚠️ INFERRED: The onboarding flow appears to be optional based on a `skip` button,
but no skip logic was found in the backend — unclear if this is tracked.
⚠️ INCOMPLETE: Payment webhook handler exists but only handles `payment_succeeded`.
No handler found for `payment_failed` or `subscription_cancelled`.
❓ UNCLEAR: The `legacy_mode` flag appears in the user model but is never set anywhere
in the current codebase. Possibly dead code or migrated feature.
Before saving, verify:
Simple: +-------+ Rounded: ╭───────╮ Heavy: ┏━━━━━━━┓
| text | │ text │ ┃ text ┃
+-------+ ╰───────╯ ┗━━━━━━━┛
Double: ╔═══════╗ Dotted: ┌╌╌╌╌╌╌╌┐
║ text ║ ╎ text ╎
╚═══════╝ └╌╌╌╌╌╌╌┘
Flow: ──► ◄── ──►──► ═══►
Vertical: │ ▲ ▼
Conditional: ─┬─ ─┤ └──
┌─────────┐
│ Action │
└────┬────┘
│
┌────▼────┐
│Decision?│
└────┬────┘
┌───┴───┐
YES NO
│ │
Actor A Actor B Actor C
│ │ │
│──action─────►│ │
│ │──action─────►│
│ │◄─response────│
│◄─response────│ │
Always save the final spec to:
/mnt/user-data/outputs/<project-name>-spec.md
Then use present_files to share it with the user.
Finish with a brief summary: number of features documented, screens drawn, AI integrations found, and business rules catalogued.
tools
Auto-initialize structured documentation for any project using lat.md (knowledge graph of markdown files with [[wiki links]], // @lat: code refs, and semantic search). Detects cali-product-workflow artifacts (spec-product.md, spec-tech.md, critiques) and uses them as seed material. Falls back to extracting business rules, architecture, and design decisions directly from the codebase. Use when a project lacks structured documentation or when lat.md/ is missing. After seeding, lat.md extension hooks keep documentation alive automatically.
testing
[Cali] Server security audit and hardening for private servers behind Tailscale. Use when: auditing server security, hardening SSH/firewall/Docker, checking for vulnerabilities, setting up fail2ban, reviewing port exposure, or responding to security alerts. Covers 6 layers: CloudFlare, UFW, Tailscale, SSH, Docker, Application. Triggers: "server security", "security audit", "harden server", "SSH hardening", "firewall rules", "UFW config", "fail2ban", "port security", "Docker security", "vulnerability check", "security review".
tools
Run supply chain security scans before installing packages or before releases. Triggers when: user installs a package (npm, pip, go get, brew), user asks to 'scan dependencies', 'check vulnerabilities', 'supply chain', 'security audit', 'run trivy', 'run socket', or before any release/deployment. Also triggers on mentions of: socket.dev, trivy, OSV-scanner, dotenvx, CVE, dependency audit. Covers all four tools with concrete commands.
tools
Create GitHub releases following project conventions. Triggers when: user says 'release', 'create release', 'push release', 'deploy to main', 'merge to main', user merges a PR to main, or when git push to main is detected. Also triggers on mentions of: gh release, semver, version bump, changelog, release-please. Covers: config-driven (read .release.yml and execute) and fallback (gh CLI) release flows, versioning rules, tag management, and the mandatory release-on-merge convention.