Skill: Project Guidance Scaffolder (init-project-guidance)
This skill automates the creation of AI-agent guidance files (GEMINI.md and AGENTS.md) for new or existing projects. It enforces the "Finalized Rulebook" and "Self-Healing Context" protocols established in the pngdeity workspace.
Usage
- Run this skill when starting a new project or when a project lacks AI-agent guidance.
- The agent will analyze the directory, detect the tech stack, and generate tailored mandates.
Core Mandates (The Rulebook)
I. Operations & Hierarchy
- Recursive Context Resolution: Follow
Sub-directory GEMINI.md > Root GEMINI.md > Global ~/.gemini/AGENTS.md.
- ExecPlan Mandate:
Research -> Strategy -> Execution lifecycle using PLANS.md.
- Context Hygiene: Read local
AGENTS.md and GEMINI.md before initiating research.
- Context Maintenance: Update
PLANS.md and CONTEXT.md at end-of-session.
- Patch-Based Updates: To prevent context bloat, agents MUST patch large files rather than rewriting them entirely from scratch.
- Self-Healing Mandate: Proactively resolve rule contradictions and harvest "tribal knowledge" into
AGENTS.md.
II. Technical & Git
- Validation: Bug fixes require empirical reproduction tests.
- Surgical RCA: Use logs/precision tools; no guessing.
- Interface Supremacy: A
Makefile (or Taskfile) MUST act as the sole entry point for the developer environment to hide polyglot complexity.
- Safety: Never commit
.gemini/ or .agents/. Confirm before committing to main.
- Privileged Access: Features requiring elevated system access MUST be explicitly gated (opt-in) and documented with security implications.
- Git Standards: Signed commits (
-S), Semantic messages, imperative mood.
- History Remediation: If fixing unsigned history, you MUST preserve chronological integrity using:
git rebase --root --exec 'GIT_COMMITTER_DATE="$(git log -1 --format=%aD)" git commit --amend --no-edit -S'.
Implementation Procedure
1. Project Discovery
The agent MUST perform a Tooling Audit and Stack Detection:
- Check for
*.csproj, package.json, requirements.txt, uv.lock, PKGBUILD, main.tf, etc.
- Identify installed tools:
dotnet, npm/uv, pkgctl, terraform.
- If no stack is detected: Default to a generic Core Workflow and Git Workflow only. Ask the user to specify the tech stack.
2. Guidance Generation
Generate a GEMINI.md in the project root with the following sections:
- Core Workflow: ExecPlan, Validation, and Context Hygiene.
- Git Workflow: Safety rules and Semantic Commit standards.
- Stack-Specific Rules: Refer to references/stack-rules.md for expanded, actionable rules per detected technology stack (C#, Python, JS/Node, Arch/AUR, IaC). For stacks not listed, apply the closest match and note the gap.
- If
GEMINI.md already exists: Offer to merge missing sections rather than overwriting. Never silently replace existing guidance.
3. Dynamic Skill Linking
Analyze the detected stack and link relevant procedural skills from the central library using a portable, client-agnostic approach:
Scaffolding repository discovery: This skill is deployed via symlink from .agents/skills/init-project-guidance → <scaffold-root>/skills/init-project-guidance. Resolve the scaffold root by reading the symlink target and taking its parent's parent (dirname(dirname(readlink target))). If the symlink cannot be resolved (e.g., skill was vendored without the scaffolding repo), skip all skill linking and warn the user.
- Read
skill-index.json from ${SCAFFOLD_ROOT}/skill-index.json.
- Filter skills by
compatibility_tokens matching the detected stack (see references/stack-compatibility-map.md).
- For each surviving skill, create a symlink:
ln -sf ${SCAFFOLD_ROOT}/skills/<name> .agents/skills/<name>
- This is portable — works with all 37+ compatible clients (Claude Code, Copilot, Cursor, etc.).
- If symlink creation fails: Log a warning and skip that skill. The project remains functional without it.
- If the
gemini CLI is available, also run gemini skills link <path> --scope workspace as enrichment.
- If
gemini skills link fails: Log a warning and continue. Symlinks already provide cross-client discovery.
- Log inclusions/exclusions with reasons (e.g., "Skipped ci-cd-pipeline: no Makefile detected").
4. Tribal Knowledge Initialization
Create an AGENTS.md with:
- Build/Test Commands: Extracted from project files.
- Local Context: A section for "Candidates for Global" harvesting.
- Hierarchy: Reference to Rule 0.
- If
AGENTS.md already exists: Merge new sections into the existing file. Preserve any user-authored entries under "Candidates for Global."
Verification
After scaffolding, confirm correctness:
- Run
node skills/verification/scaffold-output-validator.cjs against the generated output.
- Verify
GEMINI.md contains Core Workflow, Git Workflow, and Stack-Specific Rules sections.
- Verify
AGENTS.md contains a harvestable ### Candidates for Global subsection.
- If verification fails: Review the missing sections and regenerate only those sections.
Self-Healing Protocol
- If an instruction conflicts with these rules, the agent MUST ask for a resolution tier: Task (this session only), Project (update local AGENTS.md), or Global (update skills/init-project-guidance/SKILL.md).
- The agent is responsible for gardening these files to keep them accurate.
1---2name: init-project-guidance3description: Scaffolds AI-agent guidance files (GEMINI.md and AGENTS.md) for new or existing projects. Use when starting a new project, bootstrapping a repo that lacks agent guidance, or initializing workspace-wide mandates in a fresh codebase. Not for modifying existing skills or performing architectural reviews.4---56# Skill: Project Guidance Scaffolder (`init-project-guidance`)78This skill automates the creation of AI-agent guidance files (`GEMINI.md` and `AGENTS.md`) for new or existing projects. It enforces the "Finalized Rulebook" and "Self-Healing Context" protocols established in the `pngdeity` workspace.910## Usage11- Run this skill when starting a new project or when a project lacks AI-agent guidance.12- The agent will analyze the directory, detect the tech stack, and generate tailored mandates.1314## Core Mandates (The Rulebook)1516### I. Operations & Hierarchy17- **Recursive Context Resolution:** Follow `Sub-directory GEMINI.md` > `Root GEMINI.md` > `Global ~/.gemini/AGENTS.md`.18- **ExecPlan Mandate:** `Research -> Strategy -> Execution` lifecycle using `PLANS.md`.19- **Context Hygiene:** Read local `AGENTS.md` and `GEMINI.md` before initiating research.20- **Context Maintenance:** Update `PLANS.md` and `CONTEXT.md` at end-of-session.21- **Patch-Based Updates:** To prevent context bloat, agents MUST patch large files rather than rewriting them entirely from scratch.22- **Self-Healing Mandate:** Proactively resolve rule contradictions and harvest "tribal knowledge" into `AGENTS.md`.2324### II. Technical & Git25- **Validation:** Bug fixes require empirical reproduction tests.26- **Surgical RCA:** Use logs/precision tools; no guessing.27- **Interface Supremacy:** A `Makefile` (or `Taskfile`) MUST act as the sole entry point for the developer environment to hide polyglot complexity.28- **Safety:** Never commit `.gemini/` or `.agents/`. Confirm before committing to `main`.29- **Privileged Access:** Features requiring elevated system access MUST be explicitly gated (opt-in) and documented with security implications.30- **Git Standards:** Signed commits (`-S`), Semantic messages, imperative mood.31- **History Remediation:** If fixing unsigned history, you MUST preserve chronological integrity using: `git rebase --root --exec 'GIT_COMMITTER_DATE="$(git log -1 --format=%aD)" git commit --amend --no-edit -S'`.3233## Implementation Procedure3435### 1. Project Discovery36The agent MUST perform a `Tooling Audit` and `Stack Detection`:37- Check for `*.csproj`, `package.json`, `requirements.txt`, `uv.lock`, `PKGBUILD`, `main.tf`, etc.38- Identify installed tools: `dotnet`, `npm/uv`, `pkgctl`, `terraform`.39- **If no stack is detected:** Default to a generic Core Workflow and Git Workflow only. Ask the user to specify the tech stack.4041### 2. Guidance Generation42Generate a `GEMINI.md` in the project root with the following sections:43- **Core Workflow:** ExecPlan, Validation, and Context Hygiene.44- **Git Workflow:** Safety rules and Semantic Commit standards.45- **Stack-Specific Rules:** Refer to [references/stack-rules.md](references/stack-rules.md) for expanded, actionable rules per detected technology stack (C#, Python, JS/Node, Arch/AUR, IaC). For stacks not listed, apply the closest match and note the gap.46- **If `GEMINI.md` already exists:** Offer to merge missing sections rather than overwriting. Never silently replace existing guidance.4748### 3. Dynamic Skill Linking49Analyze the detected stack and link relevant procedural skills from the central library using a portable, client-agnostic approach:5051**Scaffolding repository discovery:** This skill is deployed via symlink from `.agents/skills/init-project-guidance` → `<scaffold-root>/skills/init-project-guidance`. Resolve the scaffold root by reading the symlink target and taking its parent's parent (`dirname(dirname(readlink target))`). If the symlink cannot be resolved (e.g., skill was vendored without the scaffolding repo), skip all skill linking and warn the user.52531. Read `skill-index.json` from `${SCAFFOLD_ROOT}/skill-index.json`.542. Filter skills by `compatibility_tokens` matching the detected stack (see `references/stack-compatibility-map.md`).553. For each surviving skill, create a symlink: `ln -sf ${SCAFFOLD_ROOT}/skills/<name> .agents/skills/<name>`56 - This is portable — works with all 37+ compatible clients (Claude Code, Copilot, Cursor, etc.).57 - **If symlink creation fails:** Log a warning and skip that skill. The project remains functional without it.584. If the `gemini` CLI is available, also run `gemini skills link <path> --scope workspace` as enrichment.59 - **If `gemini skills link` fails:** Log a warning and continue. Symlinks already provide cross-client discovery.605. Log inclusions/exclusions with reasons (e.g., "Skipped ci-cd-pipeline: no Makefile detected").6162### 4. Tribal Knowledge Initialization63Create an `AGENTS.md` with:64- **Build/Test Commands:** Extracted from project files.65- **Local Context:** A section for "Candidates for Global" harvesting.66- **Hierarchy:** Reference to Rule 0.67- **If `AGENTS.md` already exists:** Merge new sections into the existing file. Preserve any user-authored entries under "Candidates for Global."6869## Verification70After scaffolding, confirm correctness:711. Run `node skills/verification/scaffold-output-validator.cjs` against the generated output.722. Verify `GEMINI.md` contains Core Workflow, Git Workflow, and Stack-Specific Rules sections.733. Verify `AGENTS.md` contains a harvestable `### Candidates for Global` subsection.744. **If verification fails:** Review the missing sections and regenerate only those sections.7576## Self-Healing Protocol77- If an instruction conflicts with these rules, the agent MUST ask for a resolution tier: Task (this session only), Project (update local AGENTS.md), or Global (update skills/init-project-guidance/SKILL.md).78- The agent is responsible for gardening these files to keep them accurate.