domain-extract
Skill8 starsChanged 7 months agoMITView on GitHub
Extract domain knowledge from existing project sources and generate domain rules. Also handles vault sync and domain listing.
In this repository20 other files it gives its agents.
- .claude/rules/agents.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- audit-projectSkill
- bootstrap-projectSkill
- capture-practiceSkill
- diff-projectSkill
- export-configSkill
- forge-behaviorSkill
- init-projectSkill
- learn-projectSkill
- mcp-addSkill
- plugin-generatorSkill
- reset-projectSkill
- rule-effectivenessSkill
- scout-reposSkill
- session-insightsSkill
- sync-all-reposSkill
- sync-templateSkill
- update-practicesSkill
- watch-upstreamSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
19 rules. About 0 are common, 12 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈12
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 22
Read these project sources (skip any that don't exist):
- Distinctive: line 27
Read MEMORY.md index, then read each linked memory file
- Very specific: line 88
STOP and WAIT for the user to respond to each proposal (y/n/edit).
- Distinctive: line 90
If the user says "edit", ask what to change and regenerate that specific proposal.
- Distinctive: line 91
If the user says "all", approve all proposals.
- Very specific: line 97
Create .claude/rules/domain/ directory if not exists
- Distinctive: line 98
Write the file with frontmatter:
- Distinctive: line 108
All content in English (Claude-consumed content rule)
- Very specific: line 112
If ## Role marker exists, replace content.
- Very specific: line 113
If ## Domain marker exists, replace content.
- Very specific: line 143
If no .claude/rules/domain/ exists: "No domain rules found.
- Distinctive: line 152
Read the vault note at that path
- Very specific: line 166
If approved: update the domain rule content, set last_verified to today
- Distinctive: line 167
If vault note not found: warn and skip
- Very specific: line 169
If no files have domain_source: "No vault-linked domain rules found.
- Distinctive: line 175
NEVER auto-create files without user approval — always show proposals first
- Distinctive: line 177
All generated content must be in English (Claude-consumed)
- Distinctive: line 178
Keep each domain rule file under 40 lines
- Distinctive: line 180
If a project has no meaningful domain knowledge in its sources, say so honestly — don't generate empty placeholder files
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Domain Extract
Analyze existing project sources to propose domain knowledge rules for approval.
Dispatch
Based on $ARGUMENTS after "domain":
domain extract→ Step 1-5 (full extraction)domain list→ Step 6 (list only)domain sync-vault→ Step 7 (vault sync only)
Step 1: Gather sources
Read these project sources (skip any that don't exist):
- CLAUDE.md — sections below
<!-- forge:custom -->(user-written content) - Auto-memory — resolve the project's memory directory:
- Compute project path hash: the memory lives in
~/.claude/projects/-<path-with-dashes>/memory/ - Read MEMORY.md index, then read each linked memory file
- Filter: keep only entries with business/domain content (not purely technical)
- Compute project path hash: the memory lives in
- CLAUDE_ERRORS.md — read all entries. Flag errors where the root cause is "Claude didn't know X about the business"
- Agent memory — read
.claude/agent-memory/implementer/*.mdand.claude/agent-memory/architect/*.md- Filter: keep domain-relevant learnings (business logic, API behavior, deployment procedures)
- Existing rules — read all
.claude/rules/*.md. Identify files that mix domain + technical content - Git log — run
git log --oneline -50to identify domain-related commits (keywords: fix, deploy, API, auth, config)
Step 2: Classify findings
For each piece of domain knowledge found, classify:
- Category: deploy, api-integration, business-logic, data-model, auth-flow, external-service, workflow
- Source: which file(s) it came from
- Confidence: high (explicit in CLAUDE.md/rules), medium (in memory/errors), low (inferred from git)
- Overlap: does it duplicate existing
.claude/rules/domain/*.mdcontent?
Discard:
- Pure technical patterns (import order, test fixtures, lint rules)
- Already covered by existing domain rules
- One-time fixes that won't recur
Step 3: Generate proposals
Group findings by category. For each group, propose a domain rule file:
═══ DOMAIN EXTRACT ═══
Project: {{project_name}}
Sources analyzed: {{count}}
Existing domain rules: {{count in .claude/rules/domain/}}
── PROPOSED DOMAIN RULES ──
{{number}}. {{filename}}.md (from: {{sources}})
globs: {{suggested glob patterns}}
Content preview:
"{{3-5 line summary of what the rule will contain}}"
→ Create? (y/n/edit)Also propose a Role section if CLAUDE.md doesn't have ## Role yet:
── ROLE SECTION ──
Detected role from project context:
"{{proposed role description}}"
→ Add to CLAUDE.md ## Role? (y/n/edit)And a Domain section if CLAUDE.md doesn't have ## Domain yet:
── DOMAIN SECTION ──
Detected domain context:
"{{proposed domain summary}}"
→ Add to CLAUDE.md ## Domain? (y/n/edit)Step 4: Wait for user approval
STOP and WAIT for the user to respond to each proposal (y/n/edit).
If the user says "edit", ask what to change and regenerate that specific proposal. If the user says "all", approve all proposals.
Step 5: Create approved files
For each approved domain rule:
- Create
.claude/rules/domain/directory if not exists - Write the file with frontmatter:
--- globs: "{{patterns}}" description: "{{one-line description}}" domain: {{category}} last_verified: {{today YYYY-MM-DD}} --- - Content: imperative mood, concise facts, <40 lines per file
- All content in English (Claude-consumed content rule)
For approved Role/Domain sections:
- Read current CLAUDE.md
- If
## Rolemarker exists, replace content. If not, add section before## Arquitectura - If
## Domainmarker exists, replace content. If not, add section after## Role
Show summary:
═══ DOMAIN EXTRACT — DONE ═══
Created: {{N}} domain rules in .claude/rules/domain/
Updated: CLAUDE.md (Role: ✓/✗, Domain: ✓/✗)
Total domain knowledge: {{N}} filesStep 6: Domain list (for /forge domain list)
List all files in .claude/rules/domain/ with metadata:
═══ DOMAIN RULES ═══
File Domain Globs Last Verified Status
─────────────────────────────────────────────────────────────────────────────────
ratios.md trading **/*ratio*,**/*price* 2026-03-15 ⚠ stale (>90d)
deploy-vps.md infra **/*deploy*,docker-compose* 2026-03-25 ✓ current
jira-api.md jira **/*jira*,**/*issue* 2026-03-20 ✓ currentStatus rules:
✓ current— last_verified within 90 days⚠ stale— last_verified older than 90 days✗ no date— missing last_verified field
If no .claude/rules/domain/ exists: "No domain rules found. Run /forge domain extract to generate from existing sources."
Step 7: Vault sync (for /forge domain sync-vault)
For each file in .claude/rules/domain/ that has domain_source: vault://... in frontmatter:
- Resolve path: replace
vault://with~/vault/ - Read the vault note at that path
- Compare key facts in the vault note vs the domain rule
- If differences found:
══ VAULT SYNC ══ File: ratios.md Source: vault://decisions/ratio-engine.md Changes detected: + New: "ONs use factor 0.001 for sub-peso bonds" ~ Changed: exit ratio now uses mid-price, not ask → Update domain rule? (y/n/edit) - If approved: update the domain rule content, set
last_verifiedto today - If vault note not found: warn and skip
If no files have domain_source: "No vault-linked domain rules found. Add domain_source: vault://path to a domain rule frontmatter to enable sync."
Constraints
- NEVER auto-create files without user approval — always show proposals first
- Domain rules go in
.claude/rules/domain/, never in.claude/rules/root - All generated content must be in English (Claude-consumed)
- Keep each domain rule file under 40 lines
- Frontmatter fields: globs (required), description (required), domain (required), last_verified (required), domain_source (optional)
- If a project has no meaningful domain knowledge in its sources, say so honestly — don't generate empty placeholder files
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

