rtl-p4s-refactor-policy

rtl-p4s-refactor-policy is a skill for Claude Code from babyworm/rtl-agent-team. It costs 26 tokens per session (874 once invoked), scanned A, original, MIT.

An internal policy for deciding when and how to refactor RTL. It defines structural thresholds, naming conventions, and common changes such as standardizing ports, clocks, resets, instances, and signal types.

In plain words
What is it for?
Use it as a reference when planning RTL cleanup, auditing names and coding conventions, or deciding whether a module should be split, combined, or parameterized.
Why use it?
It gives the refactoring workflow consistent rules instead of relying on personal style. It also identifies patterns that can make hardware code harder to read or maintain.

Skill for Claude Code

Written for Claude Code: user-invocable in frontmatter.

Part of the rtl-agent-team plugin — 97 skills, 99 agents, 6 hooks shipped together

Good fit Use it as a reference when planning RTL cleanup, auditing names and coding conventions, or deciding whether a module should be split, combined, or parameterized.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/babyworm/rtl-agent-team/rtl-p4s-refactor-policy
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add babyworm/rtl-agent-team --skill rtl-p4s-refactor-policy
Clone the repo
git clone --depth 1 https://github.com/babyworm/rtl-agent-team

Made for: Claude Code.

Or install rtl-agent-team, the plugin that ships this one along with the rest of its 97 skills, 99 agents, 6 hooks.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for rtl-p4s-refactor-policy

README.md
[![agentmods](https://agentmods.dev/badge/skills/babyworm/rtl-agent-team/rtl-p4s-refactor-policy/github.svg)](https://agentmods.dev/skills/babyworm/rtl-agent-team/rtl-p4s-refactor-policy)
Your own site
<a href="https://agentmods.dev/skills/babyworm/rtl-agent-team/rtl-p4s-refactor-policy"><img src="https://agentmods.dev/badge/skills/babyworm/rtl-agent-team/rtl-p4s-refactor-policy/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for rtl-p4s-refactor-policy

Your own site · 80×15
<a href="https://agentmods.dev/skills/babyworm/rtl-agent-team/rtl-p4s-refactor-policy"><img src="https://agentmods.dev/badge/skills/babyworm/rtl-agent-team/rtl-p4s-refactor-policy.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 26 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 874 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00026 $0.00874
Opus 5.5 $0.00010 $0.00350
Sonnet 5.5 $0.00005 $0.00175
Haiku 4.5 $0.00003 $0.00087

Measured 14d ago against content hash 2a8f6ecde16c, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

rtl-p4s-refactor-policy scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 14d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/rtl-p4s-refactor-policy/SKILL.md · 73 lines

How it starts

The opening of the file, as written. The whole thing — 73 lines — stays where its author put it; the contents beside it link to each section on GitHub.

RTL Refactoring Policy

Refactoring Decision Criteria

  • Module >500 lines: consider splitting
  • 3+ modules share similar code: extract common module
  • Naming inconsistency flagged by rtl-critic: rename pass
  • Missing parameterization: add parameters for magic numbers
  • Refactoring is selective — not all modules need it

Naming Convention Audit Rules

Refactoring plans MUST include naming convention audit:

  • Ports: i_/o_/io_ prefix (NOT suffix _i/_o) — flag violations for correction
  • Clocks: clk (single domain) or {domain}_clk (multiple domains) — flag clk_i, clk_sys
  • Resets: rst_n (single domain) or {domain}_rst_n (multiple domains) — flag rst_ni
  • Instances: u_ prefix — flag missing prefix
  • Generates: gen_ prefix — flag missing prefix
  • logic only — flag any reg/wire usage

Common refactoring patterns:

  • data_i -> i_data, valid_o -> o_valid (suffix to prefix)
  • clk_i -> clk or sys_clk (suffix clock to conformant name)
  • rst_ni -> rst_n or sys_rst_n (suffix reset to conformant name)
  • fifo_inst -> u_fifo (missing instance prefix)
  • reg [7:0] data -> logic [7:0] data (reg to logic)

When renaming ports, prefer sv-renamer (https://github.com/babyworm/sv-renamer) when installed:

# Dry-run preview
sv_renamer.py --dir rtl/ --recursive --prefix i_ --dry-run --report json
# Apply + verify equivalence
sv_renamer.py --dir rtl/ --recursive --prefix i_
sv_semantic_diff.py --before original/ --after rtl/  # formal equivalence check

If sv-renamer is not installed, use Grep to find ALL instantiation sites across the codebase and update them in the same task.

Equivalence Proof Policy

  • Cosmetic/style-only cleanup: lint + smoke simulation sufficient
  • Any change touching combinational/sequential logic, reset, clock enable, or constraints intent: invoke equivalence-checker (RTL-vs-RTL) before completion
  • Formal equivalence via SymbiYosys (requires sv2v conversion first):
    sv2v rtl/{module}/*.sv -o rtl/{module}/{module}_v2v.v
    cd formal/ && sby -f {module}.sby   # .sby must reference _v2v.v, not .sv
    

Read the full file on GitHub · 73 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 14d ago First seen · 73 lines · 26 tokens per session scan A 2a8f6ecde16c

Subscribe to this mod's changes

rtl-p4s-refactor-policy is a skill published in the GitHub repository babyworm/rtl-agent-team (60 stars, last pushed 15d ago), licensed MIT. It adds 26 tokens to every session and 874 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-10-08.