Rat init project

From babyworm/rtl-agent-team · View interactive version

Rat init project is an AI agent skill from the GitHub repository babyworm/rtl-agent-team. Initialize RTL project workspace: directory structure, coding rules, phase guides. Run once per project. Triggers: 'init project', 'new project'.

How to use this skill

Skill file

<Purpose>

Initialize a new RTL design project with the standard directory structure, coding convention

rules, phase guides, and template files required by the 6-Phase pipeline.

This is a per-project operation — run once per new project workspace.

For EDA tool installation and environment verification, use /rtl-agent-team:rat-setup instead.

</Purpose>

<Use_When>

</Use_When>

<Do_Not_Use_When>

</Do_Not_Use_When>

<Why_This_Exists>

The 6-Phase pipeline expects a standard directory layout (rtl/, refc/, bfm/, sim/, lint/, syn/, etc.)

and coding convention rules deployed to .claude/rules/. Without proper project initialization,

agents fail with missing directory errors and coding conventions are not enforced.

This skill ensures the project workspace is ready before design work begins.

</Why_This_Exists>

<Execution_Policy>

rat_config.json tool detection, and regenerate config.mk

the detected environment

</Execution_Policy>

<Steps>

  1. Check plugin setup (advisory, not a hard gate):

Check ${CLAUDE_PLUGIN_DATA:-$HOME/.config/rtl-agent-team}/.setup-complete for /rtl-agent-team:rat-setup completion.

If marker is missing, advise: "Run /rtl-agent-team:rat-setup first to verify EDA tools and configure the plugin environment."

Proceed anyway — project structure can be created without tools, but warn about missing EDA environment.

1a. Check project root: Verify current directory is suitable (has .git or is empty).

  1. Create directory structure (skip existing):

```

specs/ # Input specifications and datasheets

refc/ # C reference model (DPI-C compatible)

include/ # Common ref model headers

build/ # Build output (.so for DPI-C)

bfm/ # Bus Functional Models

include/ # Common BFM headers

rtl/ # Synthesizable SystemVerilog source

common/ # Shared utility modules (ICG, synchronizer, CDC primitives)

include/ # Common defines, packages

top/ # Top-level module instantiation

sim/ # Simulation & testbenches

top/ # Tier 4: integration tests

formal/ # SVA formal verification (.sby configs)

lint/ # Lint flow

scripts/ # Lint scripts (run_lint.sh)

reports/ # Per-module lint results

syn/ # Synthesis flow

scripts/ # Synthesis scripts (run_syn.sh)

reports/ # Per-module synthesis results

docs/ # Design documentation

phase-1-research/ # Phase 1 artifacts

phase-2-architecture/ # Phase 2 artifacts

phase-3-uarch/ # Phase 3 artifacts

phase-4-rtl/ # Phase 4 artifacts

phase-5-verify/ # Phase 5 artifacts

decisions/ # Architecture Decision Records (ADR)

reviews/ # Phase gate review reports (Markdown)

phase-1-research/

phase-2-architecture/

phase-3-uarch/

phase-4-rtl/

phase-5-verify/

phase-6-review/ # Phase 6 review deliverables

.rat/

state/ # Plugin state files (auto-managed)

```

Note: Per-module subdirectories under refc/, bfm/, rtl/, sim/ are created

during Phase 2 (architecture) when module decomposition is decided.

2a. Inject project CLAUDE.md (RAT-managed section):

Run the injection script to create or update the RAT-managed section in the project root CLAUDE.md.

User content outside <!-- RAT:START --> / <!-- RAT:END --> tags is never modified.

```bash

bash "${CLAUDE_PLUGIN_ROOT}/skills/rat-init-project/scripts/inject_claude_md.sh" .

```

Idempotent — safe to re-run on every rat-init-project invocation.

2b. Generate project config (rat_config.json):

Run the config generator to detect available EDA tools and create the project configuration file.

If rat_config.json already exists, tool availability and paths are refreshed while

user-owned configuration is preserved. A usable explicit path override remains unchanged;

a stale or unusable path is replaced when the tool is found in the current environment.

```bash

bash "${CLAUDE_PLUGIN_ROOT}/skills/rat-init-project/scripts/generate_config.sh" . "$(basename "$(pwd)")"

```

The config file stores:

Users should edit per-tool env_source, technology.liberty, and waivers after generation.

config.mk is plugin-managed output and is regenerated from the refreshed configuration.

2c. Deploy rules (skip if already deployed globally via /rtl-agent-team:rat-setup):

For each rule file, check ~/.claude/rules/ first. If the same file exists globally,

skip the local copy to avoid duplicate injection. Only deploy locally if neither exists.

Diagram rules are injected into ~/.claude/CLAUDE.md by /rtl-agent-team:rat-setup via <markdown_diagram_rule> tag.

If the tag is missing (/rtl-agent-team:rat-setup not run), write an inline fallback file.

```bash

mkdir -p .claude/rules

# RTL rules: skip if global exists (no duplication)

[ ! -f ~/.claude/rules/rtl-coding-conventions.md ] && [ ! -f .claude/rules/rtl-coding-conventions.md ] && cp "${CLAUDE_PLUGIN_ROOT}/skills/rat-init-project/templates/rules/rtl-coding-conventions.md" .claude/rules/

[ ! -f ~/.claude/rules/rtl-verification-gate.md ] && [ ! -f .claude/rules/rtl-verification-gate.md ] && cp "${CLAUDE_PLUGIN_ROOT}/skills/rat-init-project/templates/rules/rtl-verification-gate.md" .claude/rules/

```

If grep -q '<markdown_diagram_rule>' ~/.claude/CLAUDE.md fails AND .claude/rules/diagram-rules.md

does not exist, use Write tool to create .claude/rules/diagram-rules.md with:

```markdown


paths:


# Diagram Policy

| Diagram Type | Tool | Use For |

|-------------|------|---------|

| Block diagram | D2 | Architecture, module hierarchy, HW block decomposition |

| Flow / Interaction | Mermaid | Pipeline stages, FSM, data/control flow, sequence diagrams |

| ASCII flow diagram | Prohibited | Do NOT use ASCII art — use D2 or Mermaid |

```

2d. Deploy guides (copy CLAUDE.md to each directory if not already present):

```bash

# Copy guide files as CLAUDE.md into each artifact directory (non-destructive)

[ ! -f rtl/CLAUDE.md ] && cp "${CLAUDE_PLUGIN_ROOT}/skills/rat-init-project/templates/guides/rtl-guide.md" rtl/CLAUDE.md

[ ! -f sim/CLAUDE.md ] && cp "${CLAUDE_PLUGIN_ROOT}/skills/rat-init-project/templates/guides/sim-guide.md" sim/CLAUDE.md

[ ! -f docs/CLAUDE.md ] && cp "${CLAUDE_PLUGIN_ROOT}/skills/rat-init-project/templates/guides/docs-guide.md" docs/CLAUDE.md

[ ! -f reviews/CLAUDE.md ] && cp "${CLAUDE_PLUGIN_ROOT}/skills/rat-init-project/templates/guides/reviews-guide.md" reviews/CLAUDE.md

[ ! -f refc/CLAUDE.md ] && cp "${CLAUDE_PLUGIN_ROOT}/skills/rat-init-project/templates/guides/refc-guide.md" refc/CLAUDE.md

[ ! -f syn/CLAUDE.md ] && cp "${CLAUDE_PLUGIN_ROOT}/skills/rat-init-project/templates/guides/syn-guide.md" syn/CLAUDE.md

```

  1. Generate lessons-learned.md (if docs/lessons-learned.md does not exist):

Create docs/lessons-learned.md with initial header:

```markdown

# Lessons Learned

> Cross-phase knowledge base. Entries are appended after each bug fix (especially Phase 5→4 feedback).

> Agents in Phase 4/5 should read this file to avoid repeating known issues.

>

> Entry format: LL-{NNN} with sections: Symptom, Root Cause, Fix Applied, Prevention, Related (REQ IDs, module, fix commit, ADR, Phase 5 Sub-phase)


```

  1. Generate filelist templates (if rtl/ has no .f files):

| Type | Location | Required |

|------|----------|----------|

| Module-level | rtl/filelist_{module}.f | MUST exist per module |

| Top-level | rtl/filelist_top.f | MUST exist (includes module filelists) |

| TB/test | in sim/ scope | Dynamic (scripts add at runtime) |

4.5. Install run_sim.sh (if scripts/run_sim.sh does not exist):

Copy scripts/run_sim.sh and make executable:

```bash

chmod +x scripts/run_sim.sh

```

This simulator-agnostic script supports iverilog, verilator, vcs, xrun, questa.

4.7. Install EDA scripts (if script folders are empty):

Create lint, synthesis, CDC, and equivalence checking scripts plus the shared tool runner library.

All scripts use lib/tool-runner.sh for transparent Docker fallback when local tools are missing.

{plugin_root}/skills/rat-init-project/scripts/install_project_templates.sh automatically when rat-init-project starts.

4.9. Deploy project Makefile (if project root has no Makefile):

Copy the unified build system Makefile that wraps all EDA scripts:

```bash

[ ! -f Makefile ] && cp "${CLAUDE_PLUGIN_ROOT}/skills/rat-init-project/templates/Makefile" Makefile

```

Open-source tools by default (make sim, make lint, make syn, make formal).

Commercial EDA via _tool suffix (make sim_xrun, make lint_spyglass, make syn_dc).

Run make help to see all targets and variables.

4.10. Deploy UVM regression runner (if sim/uvm/scripts/ has no run_regression_uvm.sh):

```bash

mkdir -p sim/uvm/scripts

[ ! -f sim/uvm/scripts/run_regression_uvm.sh ] && cp "${CLAUDE_PLUGIN_ROOT}/skills/rtl-p5s-uvm-verify/scripts/run_regression_uvm.sh" sim/uvm/scripts/run_regression_uvm.sh && chmod +x sim/uvm/scripts/run_regression_uvm.sh

```

Multi-seed UVM regression with VCS/Xcelium/Questa, coverage merge, failure halt.

Referenced by Makefile uvm_regression target.

  1. Generate cocotb Makefile template (if sim/ has no Makefile):

Copy templates/cocotb-makefile to sim/top/Makefile as reference.

Per-module cocotb Makefiles are created in sim/{module}/Makefile during Phase 4-5.

Adapters MUST retain .DEFAULT_GOAL := sim (from the template) so bare make

runs the cocotb sim target. If a helper target (e.g. ref: to build a DPI-C

reference model) is added ABOVE the cocotb include, either keep .DEFAULT_GOAL := sim

or make the helper a prerequisite of sim (e.g. sim: ref) — otherwise bare

make no-ops with "Nothing to be done".

5.5. Deploy Phase 6 PDF Makefile (if reviews/phase-6-review/ has no Makefile):

Copy templates/phase6-pdf-makefile to reviews/phase-6-review/Makefile.

5.7. Generate SV testbench template (inform user):

Reference skills/rtl-p4s-unit-test/templates/sv-testbench-template.sv for Tier 2 unit tests.

Replace {{MODULE_NAME}} and {{DOMAIN}} placeholders when creating per-module TBs.

  1. Generate module template (if rtl/ has no .sv files):

Create rtl/include/template_module.sv demonstrating project naming conventions:

```systemverilog

// template_module.sv — Template demonstrating project coding conventions

// Style: lowRISC SV Style Guide + project overrides (i_/o_ prefix, {domain}_clk/rst_n)

module template_module

import template_module_pkg::*;

#(

parameter int DATA_WIDTH = 32

) (

input logic sys_clk, // Clock: {domain}_clk format

input logic sys_rst_n, // Reset: {domain}_rst_n format

input logic [DATA_WIDTH-1:0] i_data, // Input: i_ prefix

input logic i_valid, // Input: i_ prefix

output logic [DATA_WIDTH-1:0] o_result, // Output: o_ prefix

output logic o_ready // Output: o_ prefix

);

// Use logic only (no reg/wire), typedef enum for FSM, u_ instance prefix, gen_ generate prefix

endmodule

```

  1. Quick EDA tool status (informational only, does NOT install):

Check availability of required tools and report status.

If any required tool is missing, recommend: "Run /rtl-agent-team:rat-setup to install missing tools."

  1. Report project initialization summary:

```

## RTL Project Initialization Report

```

</Steps>

<Tool_Usage>

# Directory creation (Bash CLI)
Bash: mkdir -p specs refc/include refc/build bfm/include rtl/common rtl/include rtl/top sim/top formal lint/cdc lint/cdc/reports lint/scripts lint/lint syn/{scripts,constraints,db,vnet,svf,scr,rpt,log,temp,work} docs/phase-{1-research,2-architecture,3-uarch,4-rtl,5-verify,7-exploration} docs/decisions reviews/phase-{1-research,2-architecture,3-uarch,4-rtl,5-verify,6-review,7-exploration} .rat/state .rat/scratch

# Rules deployment (skip if already global, non-destructive)
Bash: mkdir -p .claude/rules
Bash: [ ! -f ~/.claude/rules/rtl-coding-conventions.md ] && [ ! -f .claude/rules/rtl-coding-conventions.md ] && cp "${CLAUDE_PLUGIN_ROOT}/skills/rat-init-project/templates/rules/rtl-coding-conventions.md" .claude/rules/ || true
Bash: [ ! -f ~/.claude/rules/rtl-verification-gate.md ] && [ ! -f .claude/rules/rtl-verification-gate.md ] && cp "${CLAUDE_PLUGIN_ROOT}/skills/rat-init-project/templates/rules/rtl-verification-gate.md" .claude/rules/ || true
# Diagram rules: if <markdown_diagram_rule> tag missing from ~/.claude/CLAUDE.md,
# use Write tool to create .claude/rules/diagram-rules.md with inline content (see Step 2a)

# Guide deployment (non-destructive, copy as CLAUDE.md)
Bash: [ ! -f rtl/CLAUDE.md ] && cp "${CLAUDE_PLUGIN_ROOT}/skills/rat-init-project/templates/guides/rtl-guide.md" rtl/CLAUDE.md || true
Bash: [ ! -f sim/CLAUDE.md ] && cp "${CLAUDE_PLUGIN_ROOT}/skills/rat-init-project/templates/guides/sim-guide.md" sim/CLAUDE.md || true
Bash: [ ! -f docs/CLAUDE.md ] && cp "${CLAUDE_PLUGIN_ROOT}/skills/rat-init-project/templates/guides/docs-guide.md" docs/CLAUDE.md || true
Bash: [ ! -f reviews/CLAUDE.md ] && cp "${CLAUDE_PLUGIN_ROOT}/skills/rat-init-project/templates/guides/reviews-guide.md" reviews/CLAUDE.md || true
Bash: [ ! -f refc/CLAUDE.md ] && cp "${CLAUDE_PLUGIN_ROOT}/skills/rat-init-project/templates/guides/refc-guide.md" refc/CLAUDE.md || true
Bash: [ ! -f syn/CLAUDE.md ] && cp "${CLAUDE_PLUGIN_ROOT}/skills/rat-init-project/templates/guides/syn-guide.md" syn/CLAUDE.md || true

# Quick tool status (informational)
Bash: verilator --version 2>&1 || echo "NOT_FOUND"
Bash: python3 -c "import cocotb; print(cocotb.__version__)" 2>&1 || echo "NOT_FOUND"
Bash: verible-verilog-lint --version 2>&1 || echo "NOT_FOUND"
Bash: slang --version 2>&1 || echo "NOT_FOUND"

# Template deployment (non-destructive, idempotent)
Bash: bash "${CLAUDE_PLUGIN_ROOT}/skills/rat-init-project/scripts/install_project_templates.sh" "$PWD"
Bash: [ -f rtl/filelist_top.f ] || cp "${CLAUDE_PLUGIN_ROOT}/skills/rat-init-project/templates/filelist.f" rtl/filelist_top.f
Bash: [ -f sim/top/Makefile ] || cp "${CLAUDE_PLUGIN_ROOT}/skills/rat-init-project/templates/cocotb-makefile" sim/top/Makefile
Bash: mkdir -p reviews/phase-6-review && cp -n "${CLAUDE_PLUGIN_ROOT}/skills/rat-init-project/templates/phase6-pdf-makefile" reviews/phase-6-review/Makefile
Write: rtl/include/template_module.sv — convention reference template (i_/o_ prefix, sys_clk/sys_rst_n)

All EDA tools are executed via Bash CLI directly. No MCP tool servers for EDA.

</Tool_Usage>

<Escalation_And_Stop_Conditions>

</Escalation_And_Stop_Conditions>

<Final_Checklist>

</Final_Checklist>

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.