| name | skill-from-codebase |
| description | This skill should be used every time you generate, refresh, or validate codebase-derived SKILL.md documentation for this repository. |
| compatibility | opencode |
Skill-From-Codebase Generation Rules
Purpose
Define a consistent standard for generating and maintaining SKILL.md as an instruction corpus for coding agents.
SKILL.md must help agents decide what to edit, how to use public entities, and how to avoid repo-specific mistakes.
Core Principles
- Single documentation artifact - Maintain one canonical
SKILL.md at repo root.
- Instruction-first - Prefer actionable guidance over catalog-style descriptions.
- Verified facts only - Never include unverified paths, APIs, counts, or commands.
- Adaptive structure - Infer repository domains and public entity types from current codebase.
- Incremental by default when possible - Use commit baseline diffing to update only impacted sections.
- Committed-history only - Generation and refresh decisions must use committed git history, never uncommitted working-tree changes.
- Scope-sync compliant - Maintain explicit root-folder include/exclude classification and exclude docs-only paths from domain generation.
Required Files
SKILL.md at repository root - Canonical corpus file.
.nexus/ai_harness/skills/<project-name>/skills-state.json - Generation state for incremental refresh.
State file schema:
{
"skill_path": ".nexus/ai_harness/skills/<project-name>/SKILL.md",
"last_generated_commit": "<sha>",
"generated_at": "<ISO-8601>"
}
Generation Modes
Commit Baseline Requirement
Generation is commit-based:
- Run only on a clean working tree.
- If
git status --porcelain is not empty, abort generation.
- Never derive impact analysis from unstaged, staged-but-uncommitted, or untracked files.
- Incremental diff source is strictly
last_generated_commit..HEAD.
Scope-Sync Compliance
- Classify every root folder as included or excluded before domain inference.
- Exclude documentation-only roots and paths (for example
docs/, **/*.md) from domain generation.
- Keep excluded paths available for link/source validation only.
Full Mode
Use full mode when:
SKILL.md does not exist
.nexus/ai_harness/skills/<project-name>/skills-state.json does not exist
last_generated_commit is missing/invalid
- structural changes make partial refresh unsafe
Incremental Mode
Use incremental mode when both SKILL.md and valid state exist:
- diff from
last_generated_commit..HEAD
- map changed files to impacted sections/cards
- regenerate only impacted sections/cards
- preserve untouched sections verbatim
Escalate incremental -> full when changes are broad or affect global structure (workspace topology, core manifests, large docs reshuffle).
Orchestration Workflow
The main command agent is the orchestrator. It must not delegate orchestration itself.
- Scan/Impact Analysis
- Full mode: scan full repository and infer domains.
- Incremental mode: compute changed files and impacted domains.
- Domain Subagents
- Spawn subagents per domain/impacted domain.
- Subagents return draft content, links, rules, pitfalls, and usage-card material.
- Assembly Subagent
- Spawn one assembly subagent to merge drafts into proposed
SKILL.md.
- Full mode: build full document.
- Incremental mode: patch only impacted sections/cards.
- Validator Subagent
- Spawn one validator subagent to check all quality gates.
- On failure, loop assembly + validation until pass.
- Finalize
- Write
SKILL.md only after validator pass.
- Update
.nexus/ai_harness/skills/<project-name>/skills-state.json with current HEAD.
Required SKILL.md Sections
Use this order:
# <Project Name>
- Summary paragraph (operational, concise)
## Agent Operating Rules
## Environment and Version Constraints
## Quick Task Playbooks
## Getting Started
## Workspace Overview
- Inferred domain sections
## Usage Cards
## API Reference
## Common Pitfalls
## Optional
Usage Card Standard
Do not assume component libraries. Infer dominant entity type (components, modules, endpoints, commands, services, models, etc).
Each usage card must include:
Use when
Enable/Install (if applicable)
Import/Invoke
Minimal flow (2-4 steps)
Key APIs
Pitfalls (1-2 concrete mistakes)
Source (verified internal repo path only; keep brief, non-catalog)
Usage card constraints:
Source must point to existing internal files or directories in this repository.
- For web usage cards,
Key APIs must use exact full route identifiers only (for example /api/v1/users/{id}), never shorthand names.
Quality Gates (Mandatory)
- Exactly one H1 at top.
- No broken internal links.
- No duplicate entries.
- No nonexistent files/directories.
- No stale/incorrect counts.
- No unverifiable claims.
- No generic filler text.
- Usage cards include executable guidance.
- API names in usage cards are verified against real symbols in current codebase.
- Incremental mode changed only impacted sections unless explicit escalation to full mode.
- Version strings copy manifest semantics exactly (operators and pins), e.g. React
^19.2.4.
Anti-Patterns
- Writing
llms-full.txt as part of this workflow.
- Rebuilding entire file on every run when incremental refresh is safe.
- Inventing APIs from intuition instead of symbol verification.
- Leaving stale counts/paths after code moves.
- Rewriting untouched sections during incremental updates.