Claude Code plugin that auto-generates the optimal project structure for any codebase.
Run one command on any project:
/platxa-project-structure:setup
The plugin:
- Preflights — warns about ancestor and managed-policy
CLAUDE.mdfiles that will load alongside what it generates - Detects your tech stack (language, framework, test runner, linter, databases, infrastructure-as-code, CI/CD)
- Detects monorepo patterns (pnpm, npm, yarn workspaces, Go workspaces, Cargo, Lerna, Nx)
- Analyzes every module (file count, LOC, complexity score)
- Finds sharp edges (dangerous patterns, security risks, high TODO density)
- Generates
.claude/rules/with path-scoped rules per module, plusinfra.mdandci.mdwhen applicable - Generates
.claude/skills/for run-tests, lint, format-check, typecheck, and audit — withallowed-tools,paths:scoping, anddisable-model-invocationon mutating skills - Generates
.claude/agents/with domain-matched subagents (security, API, database) and a complexity-triggeredrefactor-reviewerfor L/XL modules - Audits existing CLAUDE.md (flags bloat >200 lines) or generates one with bare
@importreferences - Suggests hooks using canonical Claude Code events (
PreToolUse,PostToolUse,InstructionsLoaded) — never invented event names - Reports a before/after structure score (0-100%)
claude plugin add github:platxa/platxa-project-structureNavigate to any project and run:
/platxa-project-structure:setup
| Flag | Description |
|---|---|
| (none) | Full setup — analyze and generate everything |
--dry-run |
Preview what would be created without writing any files |
--audit |
Health-check existing .claude/ structure for stale rules, dead globs, and gaps |
--update |
Fill only missing slots; never touch present files (safer than re-run) |
--with-local |
Also generate a gitignored CLAUDE.local.md for personal preferences |
--seed-memory |
Print a starter MEMORY.md template for machine-local auto memory |
+======================================================================+
| PROJECT STRUCTURE SETUP COMPLETE |
+======================================================================+
Project: my-api
Stack: Python + FastAPI | pytest | ruff
Activation mode: path-scoped (5 modules detected)
Score: 15% → 87% (+72%)
Files created:
✓ .claude/rules/api.md (paths: src/api/**)
✓ .claude/rules/auth.md (paths: src/auth/**)
✓ .claude/rules/python.md (paths: **/*.py)
✓ .claude/skills/run-tests/SKILL.md (pytest -v)
✓ .claude/skills/lint/SKILL.md (ruff check --fix)
✓ .claude/skills/format-check/SKILL.md (ruff format)
✓ .claude/skills/typecheck/SKILL.md (pyright)
✓ .claude/agents/security-reviewer.md
✓ .claude/agents/db-reviewer.md
⊘ CLAUDE.md (already exists, 85 lines — OK)
Skipped (already exist):
⊘ .claude/rules/config.md
Sharp edges documented:
⚠ connectors/ssh_tunnel.py:42 — shell=True
⚠ config/settings.py:29 — hardcoded password
Suggested hooks (add to .claude/settings.json):
🔧 PostToolUse: Run ruff check on **/*.py edits
🔧 PostToolUse: Warn on shell=True in connectors/**
🔧 PreToolUse: Block hardcoded credentials on git commit
🔧 PreToolUse: Block writes to **/migrations/**
🔧 InstructionsLoaded: Log loaded rule files for debugging
Next steps:
1. Review generated files and customize as needed
2. Review suggested hooks and add to .claude/settings.json
3. Commit .claude/ directory to version control
4. Run /platxa-project-structure:setup again after major refactors
| Language | Framework Detection | Rule Template | Database Rules | Agent Generation |
|---|---|---|---|---|
| Python | FastAPI, Django, Flask | ✓ | PostgreSQL, MongoDB, Redis | ✓ |
| TypeScript | Next.js (App Router/Pages), Express, NestJS | ✓ | PostgreSQL, MongoDB, Redis | ✓ |
| Go | Gin, Echo, stdlib | ✓ | — | ✓ |
| Rust | Actix, Tokio, Axum | ✓ | — | ✓ |
| Other | Generic detection | ✓ | — | ✓ |
The plugin detects and handles monorepos automatically:
| Workspace Tool | Detection |
|---|---|
| pnpm | pnpm-workspace.yaml |
| npm/yarn | workspaces in package.json |
| Lerna | lerna.json |
| Go | go.work or multiple go.mod files |
| Cargo | [workspace] in Cargo.toml |
| Nx | nx.json |
Each workspace package becomes a separate module with its own rule file. Mixed-language monorepos (e.g., TypeScript frontend + Python API) get language-specific rules per package.
The plugin never overwrites existing files. If .claude/rules/api.md already exists, it skips it and reports. Re-running is always safe.
your-project/
├── CLAUDE.md ← Generated if missing (audited if exists)
├── CLAUDE.local.md ← Optional (--with-local), gitignored
└── .claude/
├── rules/
│ ├── api.md ← paths: src/api/**/*.py
│ ├── auth.md ← paths: src/auth/**/*.py
│ ├── database.md ← paths: src/database/**/*.py
│ ├── python.md ← paths: **/*.py (language-wide + framework rules)
│ ├── infra.md ← paths: Dockerfile, k8s/**, *.tf (if detected)
│ └── ci.md ← paths: .github/workflows/**, etc (if detected)
├── skills/
│ ├── run-tests/
│ │ └── SKILL.md ← pytest -v (auto-invocable)
│ ├── lint/
│ │ └── SKILL.md ← ruff check --fix (user-only — side effects)
│ ├── format-check/
│ │ └── SKILL.md ← ruff format (user-only — side effects)
│ ├── typecheck/
│ │ └── SKILL.md ← pyright . (auto-invocable)
│ └── audit/
│ └── SKILL.md ← /audit shortcut for --audit mode
└── agents/
├── security-reviewer.md ← Generated if auth module detected
├── api-tester.md ← Generated if API module detected
├── db-reviewer.md ← Generated if database module detected
└── refactor-reviewer.md ← Generated if any module is L/XL complexity
Every generated skill has canonical Claude Code frontmatter: name, description, allowed-tools, paths: for language-scoped activation, and disable-model-invocation: true on the two mutating skills (lint, format-check) so Claude can't auto-trigger file rewrites.
Each rule file uses path-scoped YAML frontmatter so it only loads when Claude touches files in that module:
---
paths:
- "src/auth/**/*.py"
---
# Auth Module Rules
- Never store passwords in plain text
- Always use bcrypt for hashing
- JWT tokens must have expiry < 1 hour
## Sharp Edges
- **hardcoded secret** at `config.py:42` — use environment variableFor small projects (fewer than 3 modules), rules are generated without paths: frontmatter so they load every session.
The plugin analyzes sharp edges and suggests hooks using canonical Claude Code hook events — PreToolUse, PostToolUse, InstructionsLoaded — per https://code.claude.com/docs/en/hooks. Hook configs are emitted in the correct hooks.{Event}[].matcher + hooks[] shape with if: permission rule syntax. Hooks are suggested only, never auto-written.
| Sharp Edge | Event | Semantics |
|---|---|---|
shell=True, eval(), exec() |
PostToolUse |
Warn after edit (non-blocking) |
| Hardcoded credentials | PreToolUse on Bash(git commit*) |
Block via exit code 2 |
| f-string SQL injection | PostToolUse |
Warn after edit |
dangerouslySetInnerHTML |
PostToolUse |
Warn after edit |
| Linter detected | PostToolUse |
Run lint; pipes output back via additionalContext |
| Migrations/secrets directories | PreToolUse on Edit|Write |
Block via exit code 2 |
| (debug) Rule load tracing | InstructionsLoaded |
Log which CLAUDE.md/rules loaded and why |
The baseline InstructionsLoaded diagnostic hook is always suggested — it's the canonical debug path for path-scoped rule troubleshooting per the Claude Code memory docs.
Run --audit to health-check existing rules:
/platxa-project-structure:setup --audit
Checks for:
- Modules with no rule coverage
- Rules referencing deleted files or dead globs (zero-match — verified via the
Globtool) - Bloated rule files (>50 lines) or CLAUDE.md (>200 lines)
- Skills referencing missing commands
Audit never modifies files — it only reports. You decide what to fix.
Run --update for a non-destructive refresh after adding a new module or upgrading the plugin:
/platxa-project-structure:setup --update
Fills only the missing slots. Every existing file is left untouched. Safer than delete-and-rerun, sharper than the default (which also skips existing files but runs the full generation plan).
A Bash-based token validator guards against template drift:
bash tests/validate-tokens.shIt enumerates every {{TOKEN}} used in templates/, skills/, and agents/, then asserts:
- Every used token is in the
ALLOWED_TOKENSregistry - Every allowed token is actually used (no orphans)
- Every used token is documented in
skills/setup/references/templates.md - Direct-mapped tokens have their source field in
agents/project-analyzer.md's output schema
Run it after any template edit. Exits non-zero on any mismatch.
This plugin exclusively emits official Claude Code primitives — nothing invented, nothing proprietary. Use this table to understand what each generated file is and how Claude consumes it:
| Plugin output | Claude Code primitive | Docs | Loading behavior |
|---|---|---|---|
CLAUDE.md (generated if missing) |
Project memory | /en/memory |
Loaded in full, every session, walking up the directory tree |
.claude/rules/{module}.md with paths: frontmatter |
Path-scoped rules | /en/memory |
Just-in-time: triggers when Claude reads a matching file |
.claude/rules/{module}.md without paths: (small projects) |
Unconditional rules | /en/memory |
Loaded every session, same priority as .claude/CLAUDE.md |
.claude/skills/{name}/SKILL.md with description + paths + allowed-tools |
Agent Skills | /en/skills |
Description in context; body loads on invoke or when relevant |
.claude/skills/{name}/ with disable-model-invocation: true |
User-only skill | /en/skills#control-who-invokes-a-skill |
Hidden from Claude; must be invoked via /skill-name |
.claude/agents/{domain}.md |
Subagent | /en/sub-agents |
Isolated context window when delegated |
Suggested hooks.{PreToolUse,PostToolUse,InstructionsLoaded} in settings.json |
Hooks | /en/hooks |
Fire on lifecycle events; PreToolUse exit 2 blocks tools |
@import references inside generated CLAUDE.md |
Memory imports | /en/memory |
Expanded at launch, max 5-hop recursion |
What the plugin does not touch:
- Auto memory (
~/.claude/projects/<repo>/memory/MEMORY.md) — machine-local, written by Claude itself across sessions. Coexists with the rules this plugin generates. See/en/memory#auto-memory. - User-level config (
~/.claude/) — personal preferences are yours to maintain. - Managed policy (
/etc/claude-code/CLAUDE.md) — organization-level settings deployed by IT.
Prompting is temporary. Structure is permanent.
This plugin implements the Claude Code Project Structure best practices:
- CLAUDE.md = Repo memory (under 200 lines, with
@importreferences) - .claude/rules/ = Path-scoped module guardrails
- .claude/skills/ = Reusable project workflows (with progressive disclosure)
- .claude/agents/ = Domain-specific subagents
- Hooks = Deterministic enforcement for critical patterns (canonical
PreToolUse/PostToolUse/InstructionsLoadedevents) - Non-destructive = Safe to re-run anytime
MIT
Made with care by DJ Patel | Platxa