---
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
title: skill-from-codebase
canonical_url: https://skilld.dev/gh/alpha-innovation-labs/opennexus-rs/skill-from-codebase
last_updated: 2026-10-06T18:42:02.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> If the user asked to install this Skill, run `npx skilld install alpha-innovation-labs/opennexus-rs/skill-from-codebase`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/skill-from-codebase`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/alpha-innovation-labs/opennexus-rs/skill-from-codebase) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/skill-from-codebase`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/skill-from-codebase --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/skill-from-codebase --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# 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

1. **Single documentation artifact** - Maintain one canonical `SKILL.md` at repo root.
2. **Instruction-first** - Prefer actionable guidance over catalog-style descriptions.
3. **Verified facts only** - Never include unverified paths, APIs, counts, or commands.
4. **Adaptive structure** - Infer repository domains and public entity types from current codebase.
5. **Incremental by default when possible** - Use commit baseline diffing to update only impacted sections.
6. **Committed-history only** - Generation and refresh decisions must use committed git history, never uncommitted working-tree changes.
7. **Scope-sync compliant** - Maintain explicit root-folder include/exclude classification and exclude docs-only paths from domain generation.

## Required Files

1. **`SKILL.md` at repository root** - Canonical corpus file.
2. **`.nexus/ai_harness/skills/<project-name>/skills-state.json`** - Generation state for incremental refresh.

State file schema:

```json
{
  "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.

1. **Scan/Impact Analysis**
   - Full mode: scan full repository and infer domains.
   - Incremental mode: compute changed files and impacted domains.
2. **Domain Subagents**
   - Spawn subagents per domain/impacted domain.
   - Subagents return draft content, links, rules, pitfalls, and usage-card material.
3. **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.
4. **Validator Subagent**
   - Spawn one validator subagent to check all quality gates.
   - On failure, loop assembly + validation until pass.
5. **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:

1. `# <Project Name>`
2. Summary paragraph (operational, concise)
3. `## Agent Operating Rules`
4. `## Environment and Version Constraints`
5. `## Quick Task Playbooks`
6. `## Getting Started`
7. `## Workspace Overview`
8. Inferred domain sections
9. `## Usage Cards`
10. `## API Reference`
11. `## Common Pitfalls`
12. `## 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:
1. `Use when`
2. `Enable/Install` (if applicable)
3. `Import/Invoke`
4. `Minimal flow` (2-4 steps)
5. `Key APIs`
6. `Pitfalls` (1-2 concrete mistakes)
7. `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)

1. Exactly one H1 at top.
2. No broken internal links.
3. No duplicate entries.
4. No nonexistent files/directories.
5. No stale/incorrect counts.
6. No unverifiable claims.
7. No generic filler text.
8. Usage cards include executable guidance.
9. API names in usage cards are verified against real symbols in current codebase.
10. Incremental mode changed only impacted sections unless explicit escalation to full mode.
11. Version strings copy manifest semantics exactly (operators and pins), e.g. React `^19.2.4`.

## Anti-Patterns

1. Writing `llms-full.txt` as part of this workflow.
2. Rebuilding entire file on every run when incremental refresh is safe.
3. Inventing APIs from intuition instead of symbol verification.
4. Leaving stale counts/paths after code moves.
5. Rewriting untouched sections during incremental updates.
