[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79NG8EY7XCPATF57D5P49F4":3,"skill-same:01M79NG8EY7XCPATF57D5P49F4":108},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":13,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":29,"install":30,"resources":43},"01M79NG8EY7XCPATF57D5P49F4","rules-extract",null,"Extract project-specific coding rules and domain knowledge from an existing codebase, generating structured markdown for AI agents. Use when onboarding a new project, after code review discussions about coding style, after sessions where preferences were corrected (--from-conversation), after PRs with significant review feedback (--from-pr), when rule files exceed 40k chars (--compact), or when the project structure has evolved and rules need reorganization (--restructure).","AndreHahm\u002Fandres-cc-marketplace","AndreHahm","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F80748019?v=4","01M79N2VZJT9MAJ7K695C9VXQ4","01M79N2W06PFX8BSCQ592M8K8K",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FAndreHahm\u002Fandres-cc-marketplace\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Frules-extract\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: rules-extract\ndescription: >-\n  Extract project-specific coding rules and domain knowledge from an existing codebase,\n  generating structured markdown for AI agents. Use when onboarding a new project,\n  after code review discussions about coding style, after sessions where preferences\n  were corrected (--from-conversation), after PRs with significant review feedback\n  (--from-pr), when rule files exceed 40k chars (--compact), or when the project\n  structure has evolved and rules need reorganization (--restructure).\nallowed-tools: Read Glob Grep Write Edit Agent TodoWrite Bash(git:*) Bash(gh:*) Bash(ls:*) Bash(pwd:*) Bash(node:*)\n---\n\n# Extract Rules\n\nAnalyzes existing codebase to identify what Codex would get wrong without project-specific guidance, extracting coding rules and domain knowledge as structured markdown documentation for AI agents.\n\n## Quick Start\n\n| Mode | Command | When |\n|------|---------|------|\n| Full extraction | `\u002Frules-extract` | New project — no `.Codex\u002Frules\u002F` yet |\n| Update | `\u002Frules-extract --update` | Re-scan and add new patterns (preserves existing) |\n| Restructure | `\u002Frules-extract --restructure` | Project evolved, new frameworks, or `split_output` changed |\n| Conversation | `\u002Frules-extract --from-conversation` | Extract from current or recent session |\n| Compaction | `\u002Frules-extract --compact` | Rules file exceeded 40k chars |\n| PR Review | `\u002Frules-extract --from-pr 123` | Extract from PR review comments |\n\n**Typical first run:**\n1. Optionally create `.Codex\u002Frules-extract.local.md` with `output_dir`, `language`, `split_output`\n2. Run `\u002Frules-extract` — detects stack, samples files, writes rule files\n3. Review generated files in `output_dir` (default `.Codex\u002Frules\u002F`)\n4. Run `\u002Frules-extract --update` after significant codebase changes or conversations\n\n## When to Use\n\n- Onboarding a new project with no `.Codex\u002Frules\u002F` yet\n- After code review sessions where coding preferences were corrected\n- After PRs with significant reviewer feedback on style or conventions\n- When `.Codex\u002Frules\u002F` files have grown past 40k chars (`--compact`)\n- After the codebase adds a new framework or architectural layer (`--update` or `--restructure`)\n- When `split_output` setting changes and files need format migration (`--restructure`)\n\n## When NOT to Use\n\n- Creating a rule from a single observation → use `rule-development` instead\n- Merging rules across multiple org projects → use `rules-merge` instead\n- Applying org rules to the current project → use `rules-apply` instead\n- Reviewing rule compliance against a diff → use `\u002Frules-review` instead\n\n## Usage\n\n```text\n\u002Frules-extract                      # Extract rules from codebase (initial)\n\u002Frules-extract --update             # Re-scan and add new patterns (preserve existing)\n\u002Frules-extract --restructure        # Re-analyze, reorganize structure, merge existing rules\n\u002Frules-extract --from-conversation              # Extract from current session (latest)\n\u002Frules-extract --from-conversation \u003Csession-id> # Extract from a specific session\n\u002Frules-extract --from-pr 123                   # PR in current repo\n\u002Frules-extract --from-pr owner\u002Frepo#123        # PR in another repo (URL form also accepted)\n\u002Frules-extract --from-pr 100..110              # PR range (space-separate multiple specs for cross-analysis)\n\u002Frules-extract --compact                       # Compact all over-threshold rules files (output_dir\u002F**\u002F*.md)\n\u002Frules-extract --compact path\u002Fto\u002Ffile.md ...   # Compact specific files\n```\n\n## Configuration\n\nSettings file: `rules-extract.local.md` (YAML frontmatter only, no markdown body)\n- Project-level: `.Codex\u002Frules-extract.local.md` (takes precedence)\n- User-level: `~\u002F.Codex\u002Frules-extract.local.md`\n\n| Setting | Default | Description |\n|---------|---------|-------------|\n| `target_dirs` | `[\".\"]` | Analysis target directories |\n| `exclude_dirs` | `[\".git\", \".Codex\"]` | Exclude directories (in addition to .gitignore) |\n| `exclude_patterns` | `[]` | Exclude file patterns (e.g., `*.generated.ts`, `*.d.ts`) |\n| `output_dir` | `.Codex\u002Frules` | Output directory for rule files (`.md` and `.local.md`). Inside Codex's `.Codex\u002Frules\u002F**` recursive auto-load scope — every file written here is injected into context on session start |\n| `examples_output_dir` | `.Codex\u002Frules-extras` | Output directory for `.examples.md` files. Defaults to a sibling directory outside `.Codex\u002Frules\u002F**` auto-load scope. Set to `output_dir` to opt examples into auto-load |\n| `staging_output_dir` | `.Codex\u002Frules-staging` | Staging directory for 1st-observation project-level candidates from incremental modes; 2nd-observation matches are promoted to canonical. See `references\u002Foutput-structure.md` § Configuration Details |\n| `language` | `en` | Report language (e.g., `en`, `ja`) |\n| `split_output` | `true` | Separate Principles (.md) and patterns (.local.md) |\n| `resolve_references` | `true` | Resolve file references during restructure |\n| `compaction_threshold` | `40000` | Char count threshold for `--compact` mode; files above this value are compacted. Default `40000` matches Codex's per-file warning. See `references\u002Foutput-structure.md` § Configuration Details |\n| `min_cluster_size` | `3` | Minimum bullet cluster size for consolidation detection in `--compact` mode. See `references\u002Foutput-structure.md` § Configuration Details |\n\nSee `references\u002Foutput-structure.md` § Configuration YAML for a full example with all settings.\n\n## Output Structure\n\nThree output directories: `output_dir` (rule files — inside `.Codex\u002Frules\u002F**` auto-load scope), `examples_output_dir` (`.examples.md` files — outside auto-load by default), `staging_output_dir` (1st-observation project-level candidates from incremental modes). The `paths:` frontmatter on rule files is a human-facing scope hint; auto-load is determined by directory placement only.\n\nSee `references\u002Foutput-structure.md` for directory tree diagrams (default, hybrid, integration libraries), YAML config example, and rule file format.\n\n## Shared Reference Files\n\nPre-load these files before executing any mode procedure — they are referenced throughout the mode reference files:\n\n| File | Used for |\n|---|---|\n| `references\u002Fextraction-criteria.md` | Pattern classification criteria (what to extract vs. skip) |\n| `references\u002Fsecurity.md` | Security self-check patterns (run after every generation step) |\n| `references\u002Fexamples-format.md` | `.examples.md` file structure and generation procedure |\n| `references\u002Freport-templates.md` | Report format for all modes |\n\n## Processing Flow\n\n### Mode Detection\n\nCheck arguments to determine mode:\n\n- No arguments → **Full Extraction Mode**\n- `--update` → **Update Mode**\n- `--restructure` → **Restructure Mode**\n- `--from-conversation [session-id]` → **Conversation Extraction Mode**\n- `--compact [\u003Cpaths>]` → **Compaction Mode**\n- `--from-pr \u003Cnumber|owner\u002Frepo#number|range> [...]` → **PR Review Extraction Mode**\n\n---\n\n## Full Extraction Mode\n\nLoad settings, detect project type, collect sample files, analyze by category (using pre-loaded `extraction-criteria.md`), analyze documentation and deduplicate against existing rules, generate output per `split_output` mode with security self-check, and report.\n\nRead `references\u002Ffull-extraction-mode.md` for the complete procedure (Steps 1–7).\n\n---\n\n## Update Mode\n\nWhen `--update` is specified, re-scan the codebase and add new patterns while preserving existing rules.\n\n**Staging awareness**: Update Mode reads the staging file under `staging_output_dir` (when present) and promotes any staged project-level patterns that re-match against fresh code observations to canonical (`\u003Coutput_dir>\u002Fproject.md`), removing them from staging. Update Mode does **not** write new entries to staging — un-matched new patterns land directly in canonical. See `references\u002Fconversation-mode.md` § Mode interaction summary for the full per-mode staging behavior.\n\n**Operational note**: After a dependency's major-version bump, run `--update` so the Step U3 staleness check flags removed symbols. The check only scans inline `` `symbol` `` in `.local.md`'s `## Project-specific patterns` — `.examples.md` is not auto-scanned. `--restructure` is not a substitute here: it reorganizes files without running the staleness check.\n\nRead `references\u002Fupdate-mode.md` for the complete procedure (Steps U1–U6).\n\n---\n\n## Restructure Mode\n\nWhen `--restructure` is specified, re-analyze the codebase to determine the optimal file structure, then merge existing rule content into the new structure. Use when the project has evolved (new frameworks, architectural changes), when `split_output` settings change, or after updating the rules-extract skill itself.\n\n**Note**: Restructure Mode does NOT run the staleness check — use `--update` first so stale symbols are flagged for manual review.\n\nRead `references\u002Frestructure-mode.md` for the complete procedure (Steps R1–R5).\n\n---\n\n## Conversation Extraction Mode\n\nWhen `--from-conversation` is specified, extract rules from the full conversation history stored in session `.jsonl` files. The heavy processing (jsonl parsing, analysis, rule writing) is delegated to a subagent to keep the main context clean.\n\n### Step C1: Prepare and Locate Session File (main agent)\n\n1. Load settings from `rules-extract.local.md` (same as Step 1 in `references\u002Ffull-extraction-mode.md`)\n\n2. Check if output directory exists (default: `.Codex\u002Frules\u002F`)\n   - If not exists: Error \"Run \u002Frules-extract first to initialize rule files.\"\n\n3. **Locate the session file:**\n\n   1. Get the current working directory (`pwd`)\n   2. Encode the path: replace `\u002F` and `.` with `-` (leading `-` is kept)\n      - Example: `\u002FUsers\u002Fhiropon\u002FSources\u002Fgithub.com\u002Fmyproject` → `-Users-hiropon-Sources-github-com-myproject`\n   3. Session files are stored at: `~\u002F.Codex\u002Fprojects\u002F\u003Cencoded-path>\u002F\u003Csession-id>.jsonl`\n\n4. **Select the target session:**\n\n   - If a `\u003Csession-id>` argument is provided: use `~\u002F.Codex\u002Fprojects\u002F\u003Cencoded-path>\u002F\u003Csession-id>.jsonl`\n   - If no argument: use the most recently modified `.jsonl` file in the directory (by `ls -t`)\n   - Verify the file exists. Inform the user which session file was selected.\n\n### Step C2: Delegate to Subagent (main agent)\n\nSpawn a subagent using the Agent tool. The subagent performs all heavy processing (C3–C5) and returns a summary of what was added. Read `references\u002Fconversation-mode.md` for the full subagent instructions (Steps C3–C5).\n\nInclude in the agent prompt:\n- This skill's absolute directory path (where SKILL.md resides — needed to run bundled scripts)\n- Session file absolute path\n- `output_dir`, `examples_output_dir`, and `staging_output_dir` paths, plus `split_output` \u002F `language` settings\n- `canonical_files`: list of existing rule file paths for canonical-match deduplication — include both rule files under `output_dir` and `.examples.md` files under `examples_output_dir`\n- `staging_files`: list of existing staging file paths for staging-match detection — include the project-level staging file under `staging_output_dir`\n- The subagent instructions from `references\u002Fconversation-mode.md`\n- Contents of `references\u002Fextraction-criteria.md` (Step C4 uses for classification criteria)\n- Contents of `references\u002Fsecurity.md` (Step C5 item 7 security self-check)\n- Contents of `references\u002Fexamples-format.md` (Step C5 item 6 examples generation)\n- Contents of `references\u002Freport-templates.md` (Step C5 item 8 summary format)\n\nAfter the subagent completes, report the results to the user.\n\n---\n\n## Compaction Mode\n\nWhen `--compact` is specified, compact over-threshold rules files. Target file selection, char-count check, and threshold filtering all happen inside this mode — orchestrating callers invoke `--compact` without file arguments.\n\nUses the Pattern A iteration loop: main thread resolves targets → subagent analyzes → main thread applies `mechanical_edits` → fenced JSON return contract for caller dispatch. Per-file outer loop with `max_iterations = 2` (default).\n\nRead `references\u002Fcompaction-orchestration.md` for the full orchestration steps: CP1 (load settings + resolve targets), CP2 (per-file iteration loop: dispatch, parse, apply, converge), CP3 (security self-check), CP4 (structured JSON output schema), CP5 (sub-skill caller directive). For subagent heuristics and contract, see `references\u002Fcompaction-mode.md`.\n\n---\n\n## PR Review Extraction Mode\n\nWhen `--from-pr` is specified, extract rules from PR review comments (human comments only).\nSingle or multiple PRs can be specified. Numbers and URLs can be mixed. Cross-repository PRs are allowed.\n\nRead `references\u002Fpr-review-mode.md` for the full processing steps (P1-P5). Key flow:\n1. Check prerequisites (`gh` CLI authentication)\n2. Parse all PR arguments, validate each PR exists\n3. Fetch review comments from GitHub API (3 endpoints per PR), filter bot comments\n4. Extract principles and patterns (per pre-loaded `extraction-criteria.md`)\n5. **Multiple PRs**: Cross-PR frequency analysis — general best practices that are repeatedly pointed out across different PRs are promoted as organizational emphasis\n6. Append to existing rule files and update `.examples.md` (same as Step C5)\n\n---\n\n## Testing & Validation\n\nAfter running rules-extract:\n\n1. **Output present** — `output_dir` (default `.Codex\u002Frules\u002F`) contains files matching the detected stack\n2. **Split format** — with `split_output: true`: `.md` has `## Principles` only, `.local.md` has `## Project-specific patterns` only\n3. **Security** — no tokens, secrets, or internal URLs in generated files (Step 6.5 passed)\n4. **No stale symbols** — Step U3 (Update Mode) flags symbols no longer in codebase; review before accepting\n5. **Deduplication** — patterns already in existing rule files are not re-added\n\n**Quality gates:**\n- [ ] Each detected language\u002Fframework has a corresponding rule file in `output_dir`\n- [ ] `paths:` frontmatter present on all rule files (except `project.md`)\n- [ ] `.examples.md` files written to `examples_output_dir` (outside auto-load scope by default)\n- [ ] No patterns duplicated between `.md` and `.local.md` sibling files\n- [ ] `\u002Frules-review` fires on known violations from the extracted rules\n\n---\n\n## Reference Guide\n\n| Resource | Purpose |\n|---|---|\n| `references\u002Fextraction-criteria.md` | Classification criteria — what to extract vs. skip |\n| `references\u002Fintegration-criteria.md` | Detection rules and output routing for integration libraries |\n| `references\u002Fsecurity.md` | Security self-check patterns — run after every generation step |\n| `references\u002Fexamples-format.md` | `.examples.md` file structure, Good\u002FBad guidelines, reference section format |\n| `references\u002Freport-templates.md` | Report format for all modes |\n| `references\u002Foutput-structure.md` | Directory tree diagrams, YAML config example, rule file format |\n| `references\u002Ffull-extraction-mode.md` | Complete procedure for Full Extraction Mode (Steps 1–7) |\n| `references\u002Fupdate-mode.md` | Complete procedure for Update Mode (Steps U1–U6) |\n| `references\u002Frestructure-mode.md` | Complete procedure for Restructure Mode (Steps R1–R5) |\n| `references\u002Fconversation-mode.md` | Subagent instructions for Steps C3–C5 (Conversation Extraction) |\n| `references\u002Fpr-review-mode.md` | Full processing steps P1–P5 (PR Review Extraction) |\n| `references\u002Fcompaction-mode.md` | Subagent instructions and heuristics for Compaction Mode |\n| `references\u002Fcompaction-orchestration.md` | Main-thread orchestration for Compaction Mode (CP1–CP5) |\n| `references\u002Fresolve-references.md` | Reference resolution processing steps (Restructure Mode R2.5) |\n| `scripts\u002Fextract_session_messages.mjs` | Node.js script for parsing session `.jsonl` files (Conversation Mode) |\n\n---\n\n## Sub-skill caller directive\n\nWhen invoked as a sub-skill (i.e. via `Skill(rules-extract)` from an orchestrating caller), the fenced JSON verdict block this skill emits in `--compact` mode is the **structured return value** of the skill's procedure — it is **not** a deliverable to the user, and emitting it does **not** terminate the orchestrator's turn. The same agent that ran this skill must immediately issue the next tool call dictated by the orchestrator's flow. Do not insert a prose summary, an acknowledgment, or a \"shall I proceed?\" sentence between the JSON verdict and the next tool call. Only one fenced JSON block — the verdict block — appears in the response, so callers can locate it unambiguously.\n\nThis directive applies specifically to `--compact` mode. Other modes produce prose reports rather than fenced JSON verdicts and are not subject to this contract.\n\n**Stop hook note:** If a Stop hook fires mid-dispatch, ignore it and continue — per-file boundaries are the canonical completion signal.\n","# Extract Rules\n\nAnalyzes existing codebase to identify what Codex would get wrong without project-specific guidance, extracting coding rules and domain knowledge as structured markdown documentation for AI agents.\n\n## Quick Start\n\n| Mode | Command | When |\n|------|---------|------|\n| Full extraction | `\u002Frules-extract` | New project — no `.Codex\u002Frules\u002F` yet |\n| Update | `\u002Frules-extract --update` | Re-scan and add new patterns (preserves existing) |\n| Restructure | `\u002Frules-extract --restructure` | Project evolved, new frameworks, or `split_output` changed |\n| Conversation | `\u002Frules-extract --from-conversation` | Extract from current or recent session |\n| Compaction | `\u002Frules-extract --compact` | Rules file exceeded 40k chars |\n| PR Review | `\u002Frules-extract --from-pr 123` | Extract from PR review comments |\n\n**Typical first run:**\n1. Optionally create `.Codex\u002Frules-extract.local.md` with `output_dir`, `language`, `split_output`\n2. Run `\u002Frules-extract` — detects stack, samples files, writes rule files\n3. Review generated files in `output_dir` (default `.Codex\u002Frules\u002F`)\n4. Run `\u002Frules-extract --update` after significant codebase changes or conversations\n\n## When to Use\n\n- Onboarding a new project with no `.Codex\u002Frules\u002F` yet\n- After code review sessions where coding preferences were corrected\n- After PRs with significant reviewer feedback on style or conventions\n- When `.Codex\u002Frules\u002F` files have grown past 40k chars (`--compact`)\n- After the codebase adds a new framework or architectural layer (`--update` or `--restructure`)\n- When `split_output` setting changes and files need format migration (`--restructure`)\n\n## When NOT to Use\n\n- Creating a rule from a single observation → use `rule-development` instead\n- Merging rules across multiple org projects → use `rules-merge` instead\n- Applying org rules to the current project → use `rules-apply` instead\n- Reviewing rule compliance against a diff → use `\u002Frules-review` instead\n\n## Usage\n\n```text\n\u002Frules-extract                      # Extract rules from codebase (initial)\n\u002Frules-extract --update             # Re-scan and add new patterns (preserve existing)\n\u002Frules-extract --restructure        # Re-analyze, reorganize structure, merge existing rules\n\u002Frules-extract --from-conversation              # Extract from current session (latest)\n\u002Frules-extract --from-conversation \u003Csession-id> # Extract from a specific session\n\u002Frules-extract --from-pr 123                   # PR in current repo\n\u002Frules-extract --from-pr owner\u002Frepo#123        # PR in another repo (URL form also accepted)\n\u002Frules-extract --from-pr 100..110              # PR range (space-separate multiple specs for cross-analysis)\n\u002Frules-extract --compact                       # Compact all over-threshold rules files (output_dir\u002F**\u002F*.md)\n\u002Frules-extract --compact path\u002Fto\u002Ffile.md ...   # Compact specific files\n```\n\n## Configuration\n\nSettings file: `rules-extract.local.md` (YAML frontmatter only, no markdown body)\n- Project-level: `.Codex\u002Frules-extract.local.md` (takes precedence)\n- User-level: `~\u002F.Codex\u002Frules-extract.local.md`\n\n| Setting | Default | Description |\n|---------|---------|-------------|\n| `target_dirs` | `[\".\"]` | Analysis target directories |\n| `exclude_dirs` | `[\".git\", \".Codex\"]` | Exclude directories (in addition to .gitignore) |\n| `exclude_patterns` | `[]` | Exclude file patterns (e.g., `*.generated.ts`, `*.d.ts`) |\n| `output_dir` | `.Codex\u002Frules` | Output directory for rule files (`.md` and `.local.md`). Inside Codex's `.Codex\u002Frules\u002F**` recursive auto-load scope — every file written here is injected into context on session start |\n| `examples_output_dir` | `.Codex\u002Frules-extras` | Output directory for `.examples.md` files. Defaults to a sibling directory outside `.Codex\u002Frules\u002F**` auto-load scope. Set to `output_dir` to opt examples into auto-load |\n| `staging_output_dir` | `.Codex\u002Frules-staging` | Staging directory for 1st-observation project-level candidates from incremental modes; 2nd-observation matches are promoted to canonical. See `references\u002Foutput-structure.md` § Configuration Details |\n| `language` | `en` | Report language (e.g., `en`, `ja`) |\n| `split_output` | `true` | Separate Principles (.md) and patterns (.local.md) |\n| `resolve_references` | `true` | Resolve file references during restructure |\n| `compaction_threshold` | `40000` | Char count threshold for `--compact` mode; files above this value are compacted. Default `40000` matches Codex's per-file warning. See `references\u002Foutput-structure.md` § Configuration Details |\n| `min_cluster_size` | `3` | Minimum bullet cluster size for consolidation detection in `--compact` mode. See `references\u002Foutput-structure.md` § Configuration Details |\n\nSee `references\u002Foutput-structure.md` § Configuration YAML for a full example with all settings.\n\n## Output Structure\n\nThree output directories: `output_dir` (rule files — inside `.Codex\u002Frules\u002F**` auto-load scope), `examples_output_dir` (`.examples.md` files — outside auto-load by default), `staging_output_dir` (1st-observation project-level candidates from incremental modes). The `paths:` frontmatter on rule files is a human-facing scope hint; auto-load is determined by directory placement only.\n\nSee `references\u002Foutput-structure.md` for directory tree diagrams (default, hybrid, integration libraries), YAML config example, and rule file format.\n\n## Shared Reference Files\n\nPre-load these files before executing any mode procedure — they are referenced throughout the mode reference files:\n\n| File | Used for |\n|---|---|\n| `references\u002Fextraction-criteria.md` | Pattern classification criteria (what to extract vs. skip) |\n| `references\u002Fsecurity.md` | Security self-check patterns (run after every generation step) |\n| `references\u002Fexamples-format.md` | `.examples.md` file structure and generation procedure |\n| `references\u002Freport-templates.md` | Report format for all modes |\n\n## Processing Flow\n\n### Mode Detection\n\nCheck arguments to determine mode:\n\n- No arguments → **Full Extraction Mode**\n- `--update` → **Update Mode**\n- `--restructure` → **Restructure Mode**\n- `--from-conversation [session-id]` → **Conversation Extraction Mode**\n- `--compact [\u003Cpaths>]` → **Compaction Mode**\n- `--from-pr \u003Cnumber|owner\u002Frepo#number|range> [...]` → **PR Review Extraction Mode**\n\n---\n\n## Full Extraction Mode\n\nLoad settings, detect project type, collect sample files, analyze by category (using pre-loaded `extraction-criteria.md`), analyze documentation and deduplicate against existing rules, generate output per `split_output` mode with security self-check, and report.\n\nRead `references\u002Ffull-extraction-mode.md` for the complete procedure (Steps 1–7).\n\n---\n\n## Update Mode\n\nWhen `--update` is specified, re-scan the codebase and add new patterns while preserving existing rules.\n\n**Staging awareness**: Update Mode reads the staging file under `staging_output_dir` (when present) and promotes any staged project-level patterns that re-match against fresh code observations to canonical (`\u003Coutput_dir>\u002Fproject.md`), removing them from staging. Update Mode does **not** write new entries to staging — un-matched new patterns land directly in canonical. See `references\u002Fconversation-mode.md` § Mode interaction summary for the full per-mode staging behavior.\n\n**Operational note**: After a dependency's major-version bump, run `--update` so the Step U3 staleness check flags removed symbols. The check only scans inline `` `symbol` `` in `.local.md`'s `## Project-specific patterns` — `.examples.md` is not auto-scanned. `--restructure` is not a substitute here: it reorganizes files without running the staleness check.\n\nRead `references\u002Fupdate-mode.md` for the complete procedure (Steps U1–U6).\n\n---\n\n## Restructure Mode\n\nWhen `--restructure` is specified, re-analyze the codebase to determine the optimal file structure, then merge existing rule content into the new structure. Use when the project has evolved (new frameworks, architectural changes), when `split_output` settings change, or after updating the rules-extract skill itself.\n\n**Note**: Restructure Mode does NOT run the staleness check — use `--update` first so stale symbols are flagged for manual review.\n\nRead `references\u002Frestructure-mode.md` for the complete procedure (Steps R1–R5).\n\n---\n\n## Conversation Extraction Mode\n\nWhen `--from-conversation` is specified, extract rules from the full conversation history stored in session `.jsonl` files. The heavy processing (jsonl parsing, analysis, rule writing) is delegated to a subagent to keep the main context clean.\n\n### Step C1: Prepare and Locate Session File (main agent)\n\n1. Load settings from `rules-extract.local.md` (same as Step 1 in `references\u002Ffull-extraction-mode.md`)\n\n2. Check if output directory exists (default: `.Codex\u002Frules\u002F`)\n   - If not exists: Error \"Run \u002Frules-extract first to initialize rule files.\"\n\n3. **Locate the session file:**\n\n   1. Get the current working directory (`pwd`)\n   2. Encode the path: replace `\u002F` and `.` with `-` (leading `-` is kept)\n      - Example: `\u002FUsers\u002Fhiropon\u002FSources\u002Fgithub.com\u002Fmyproject` → `-Users-hiropon-Sources-github-com-myproject`\n   3. Session files are stored at: `~\u002F.Codex\u002Fprojects\u002F\u003Cencoded-path>\u002F\u003Csession-id>.jsonl`\n\n4. **Select the target session:**\n\n   - If a `\u003Csession-id>` argument is provided: use `~\u002F.Codex\u002Fprojects\u002F\u003Cencoded-path>\u002F\u003Csession-id>.jsonl`\n   - If no argument: use the most recently modified `.jsonl` file in the directory (by `ls -t`)\n   - Verify the file exists. Inform the user which session file was selected.\n\n### Step C2: Delegate to Subagent (main agent)\n\nSpawn a subagent using the Agent tool. The subagent performs all heavy processing (C3–C5) and returns a summary of what was added. Read `references\u002Fconversation-mode.md` for the full subagent instructions (Steps C3–C5).\n\nInclude in the agent prompt:\n- This skill's absolute directory path (where SKILL.md resides — needed to run bundled scripts)\n- Session file absolute path\n- `output_dir`, `examples_output_dir`, and `staging_output_dir` paths, plus `split_output` \u002F `language` settings\n- `canonical_files`: list of existing rule file paths for canonical-match deduplication — include both rule files under `output_dir` and `.examples.md` files under `examples_output_dir`\n- `staging_files`: list of existing staging file paths for staging-match detection — include the project-level staging file under `staging_output_dir`\n- The subagent instructions from `references\u002Fconversation-mode.md`\n- Contents of `references\u002Fextraction-criteria.md` (Step C4 uses for classification criteria)\n- Contents of `references\u002Fsecurity.md` (Step C5 item 7 security self-check)\n- Contents of `references\u002Fexamples-format.md` (Step C5 item 6 examples generation)\n- Contents of `references\u002Freport-templates.md` (Step C5 item 8 summary format)\n\nAfter the subagent completes, report the results to the user.\n\n---\n\n## Compaction Mode\n\nWhen `--compact` is specified, compact over-threshold rules files. Target file selection, char-count check, and threshold filtering all happen inside this mode — orchestrating callers invoke `--compact` without file arguments.\n\nUses the Pattern A iteration loop: main thread resolves targets → subagent analyzes → main thread applies `mechanical_edits` → fenced JSON return contract for caller dispatch. Per-file outer loop with `max_iterations = 2` (default).\n\nRead `references\u002Fcompaction-orchestration.md` for the full orchestration steps: CP1 (load settings + resolve targets), CP2 (per-file iteration loop: dispatch, parse, apply, converge), CP3 (security self-check), CP4 (structured JSON output schema), CP5 (sub-skill caller directive). For subagent heuristics and contract, see `references\u002Fcompaction-mode.md`.\n\n---\n\n## PR Review Extraction Mode\n\nWhen `--from-pr` is specified, extract rules from PR review comments (human comments only).\nSingle or multiple PRs can be specified. Numbers and URLs can be mixed. Cross-repository PRs are allowed.\n\nRead `references\u002Fpr-review-mode.md` for the full processing steps (P1-P5). Key flow:\n1. Check prerequisites (`gh` CLI authentication)\n2. Parse all PR arguments, validate each PR exists\n3. Fetch review comments from GitHub API (3 endpoints per PR), filter bot comments\n4. Extract principles and patterns (per pre-loaded `extraction-criteria.md`)\n5. **Multiple PRs**: Cross-PR frequency analysis — general best practices that are repeatedly pointed out across different PRs are promoted as organizational emphasis\n6. Append to existing rule files and update `.examples.md` (same as Step C5)\n\n---\n\n## Testing & Validation\n\nAfter running rules-extract:\n\n1. **Output present** — `output_dir` (default `.Codex\u002Frules\u002F`) contains files matching the detected stack\n2. **Split format** — with `split_output: true`: `.md` has `## Principles` only, `.local.md` has `## Project-specific patterns` only\n3. **Security** — no tokens, secrets, or internal URLs in generated files (Step 6.5 passed)\n4. **No stale symbols** — Step U3 (Update Mode) flags symbols no longer in codebase; review before accepting\n5. **Deduplication** — patterns already in existing rule files are not re-added\n\n**Quality gates:**\n- [ ] Each detected language\u002Fframework has a corresponding rule file in `output_dir`\n- [ ] `paths:` frontmatter present on all rule files (except `project.md`)\n- [ ] `.examples.md` files written to `examples_output_dir` (outside auto-load scope by default)\n- [ ] No patterns duplicated between `.md` and `.local.md` sibling files\n- [ ] `\u002Frules-review` fires on known violations from the extracted rules\n\n---\n\n## Reference Guide\n\n| Resource | Purpose |\n|---|---|\n| `references\u002Fextraction-criteria.md` | Classification criteria — what to extract vs. skip |\n| `references\u002Fintegration-criteria.md` | Detection rules and output routing for integration libraries |\n| `references\u002Fsecurity.md` | Security self-check patterns — run after every generation step |\n| `references\u002Fexamples-format.md` | `.examples.md` file structure, Good\u002FBad guidelines, reference section format |\n| `references\u002Freport-templates.md` | Report format for all modes |\n| `references\u002Foutput-structure.md` | Directory tree diagrams, YAML config example, rule file format |\n| `references\u002Ffull-extraction-mode.md` | Complete procedure for Full Extraction Mode (Steps 1–7) |\n| `references\u002Fupdate-mode.md` | Complete procedure for Update Mode (Steps U1–U6) |\n| `references\u002Frestructure-mode.md` | Complete procedure for Restructure Mode (Steps R1–R5) |\n| `references\u002Fconversation-mode.md` | Subagent instructions for Steps C3–C5 (Conversation Extraction) |\n| `references\u002Fpr-review-mode.md` | Full processing steps P1–P5 (PR Review Extraction) |\n| `references\u002Fcompaction-mode.md` | Subagent instructions and heuristics for Compaction Mode |\n| `references\u002Fcompaction-orchestration.md` | Main-thread orchestration for Compaction Mode (CP1–CP5) |\n| `references\u002Fresolve-references.md` | Reference resolution processing steps (Restructure Mode R2.5) |\n| `scripts\u002Fextract_session_messages.mjs` | Node.js script for parsing session `.jsonl` files (Conversation Mode) |\n\n---\n\n## Sub-skill caller directive\n\nWhen invoked as a sub-skill (i.e. via `Skill(rules-extract)` from an orchestrating caller), the fenced JSON verdict block this skill emits in `--compact` mode is the **structured return value** of the skill's procedure — it is **not** a deliverable to the user, and emitting it does **not** terminate the orchestrator's turn. The same agent that ran this skill must immediately issue the next tool call dictated by the orchestrator's flow. Do not insert a prose summary, an acknowledgment, or a \"shall I proceed?\" sentence between the JSON verdict and the next tool call. Only one fenced JSON block — the verdict block — appears in the response, so callers can locate it unambiguously.\n\nThis directive applies specifically to `--compact` mode. Other modes produce prose reports rather than fenced JSON verdicts and are not subject to this contract.\n\n**Stop hook note:** If a Stop hook fires mid-dispatch, ignore it and continue — per-file boundaries are the canonical completion signal.\n",{"name":5,"description":7,"allowed-tools":23},"Read Glob Grep Write Edit Agent TodoWrite Bash(git:*) Bash(gh:*) Bash(ls:*) Bash(pwd:*) Bash(node:*)","main","1bf12900cac6f28e346abd2912bdb78d306de723",".agents\u002Fskills\u002Frules-extract","https:\u002F\u002Fgithub.com\u002FAndreHahm\u002Fandres-cc-marketplace","https:\u002F\u002Fgithub.com\u002FAndreHahm","2026-11-15 04:26:16",{"source":8,"skillName":5,"commands":31,"prompt":41,"zipAvailable":42},[32,35,38],{"tool":33,"command":34},"npx","npx skills add AndreHahm\u002Fandres-cc-marketplace --skill rules-extract",{"tool":36,"command":37},"bunx","bunx skills add AndreHahm\u002Fandres-cc-marketplace --skill rules-extract",{"tool":39,"command":40},"pnpm","pnpm dlx skills add AndreHahm\u002Fandres-cc-marketplace --skill rules-extract","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FAndreHahm\u002Fandres-cc-marketplace\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Frules-extract\u002FSKILL.md",true,[44,50,54,58,62,66,70,74,78,82,86,90,94,98,102],{"path":45,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":48,"sourceHtmlUrl":49},"references\u002Fcompaction-mode.md","REFERENCE","参考文档",28845,"https:\u002F\u002Fgithub.com\u002FAndreHahm\u002Fandres-cc-marketplace\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Frules-extract\u002Freferences\u002Fcompaction-mode.md",{"path":51,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":52,"sourceHtmlUrl":53},"references\u002Fcompaction-orchestration.md",23606,"https:\u002F\u002Fgithub.com\u002FAndreHahm\u002Fandres-cc-marketplace\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Frules-extract\u002Freferences\u002Fcompaction-orchestration.md",{"path":55,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":56,"sourceHtmlUrl":57},"references\u002Fconversation-mode.md",12021,"https:\u002F\u002Fgithub.com\u002FAndreHahm\u002Fandres-cc-marketplace\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Frules-extract\u002Freferences\u002Fconversation-mode.md",{"path":59,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":60,"sourceHtmlUrl":61},"references\u002Fexamples-format.md",8240,"https:\u002F\u002Fgithub.com\u002FAndreHahm\u002Fandres-cc-marketplace\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Frules-extract\u002Freferences\u002Fexamples-format.md",{"path":63,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":64,"sourceHtmlUrl":65},"references\u002Fextraction-criteria.md",7067,"https:\u002F\u002Fgithub.com\u002FAndreHahm\u002Fandres-cc-marketplace\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Frules-extract\u002Freferences\u002Fextraction-criteria.md",{"path":67,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":68,"sourceHtmlUrl":69},"references\u002Ffull-extraction-mode.md",10009,"https:\u002F\u002Fgithub.com\u002FAndreHahm\u002Fandres-cc-marketplace\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Frules-extract\u002Freferences\u002Ffull-extraction-mode.md",{"path":71,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":72,"sourceHtmlUrl":73},"references\u002Fintegration-criteria.md",1583,"https:\u002F\u002Fgithub.com\u002FAndreHahm\u002Fandres-cc-marketplace\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Frules-extract\u002Freferences\u002Fintegration-criteria.md",{"path":75,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":76,"sourceHtmlUrl":77},"references\u002Foutput-structure.md",6708,"https:\u002F\u002Fgithub.com\u002FAndreHahm\u002Fandres-cc-marketplace\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Frules-extract\u002Freferences\u002Foutput-structure.md",{"path":79,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":80,"sourceHtmlUrl":81},"references\u002Fpr-review-mode.md",12179,"https:\u002F\u002Fgithub.com\u002FAndreHahm\u002Fandres-cc-marketplace\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Frules-extract\u002Freferences\u002Fpr-review-mode.md",{"path":83,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":84,"sourceHtmlUrl":85},"references\u002Freport-templates.md",8789,"https:\u002F\u002Fgithub.com\u002FAndreHahm\u002Fandres-cc-marketplace\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Frules-extract\u002Freferences\u002Freport-templates.md",{"path":87,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":88,"sourceHtmlUrl":89},"references\u002Fresolve-references.md",2417,"https:\u002F\u002Fgithub.com\u002FAndreHahm\u002Fandres-cc-marketplace\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Frules-extract\u002Freferences\u002Fresolve-references.md",{"path":91,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":92,"sourceHtmlUrl":93},"references\u002Frestructure-mode.md",3780,"https:\u002F\u002Fgithub.com\u002FAndreHahm\u002Fandres-cc-marketplace\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Frules-extract\u002Freferences\u002Frestructure-mode.md",{"path":95,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":96,"sourceHtmlUrl":97},"references\u002Fsecurity.md",1104,"https:\u002F\u002Fgithub.com\u002FAndreHahm\u002Fandres-cc-marketplace\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Frules-extract\u002Freferences\u002Fsecurity.md",{"path":99,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":100,"sourceHtmlUrl":101},"references\u002Fupdate-mode.md",7012,"https:\u002F\u002Fgithub.com\u002FAndreHahm\u002Fandres-cc-marketplace\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Frules-extract\u002Freferences\u002Fupdate-mode.md",{"path":103,"resourceType":104,"resourceTypeDesc":105,"sizeBytes":106,"sourceHtmlUrl":107},"scripts\u002Fextract_session_messages.mjs","SCRIPT","脚本",6040,"https:\u002F\u002Fgithub.com\u002FAndreHahm\u002Fandres-cc-marketplace\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Frules-extract\u002Fscripts\u002Fextract_session_messages.mjs",[109,116,123,130,137,144],{"skillNo":110,"name":111,"nameZh":6,"description":112,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":113,"categories":114,"keywords":115,"publishedAt":18},"01M79R0K918Z0XDM74R0EY5H3P","demo","Fixture skill used by scripts.marketplace_ci sync tests.","https:\u002F\u002Fgithub.com\u002FAndreHahm\u002Fandres-cc-marketplace\u002Fblob\u002Fmain\u002Ftests\u002Fmarketplace_ci\u002Ffixtures\u002Fplugins\u002Fsample-kit\u002Fskills\u002Fdemo\u002FSKILL.md",[],[],{"skillNo":117,"name":118,"nameZh":6,"description":119,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":120,"categories":121,"keywords":122,"publishedAt":18},"01M79R08VMDJA2FPJKH3ZM309K","export-demo","Fixture skill used by scripts.marketplace_ci export tests.","https:\u002F\u002Fgithub.com\u002FAndreHahm\u002Fandres-cc-marketplace\u002Fblob\u002Fmain\u002Ftests\u002Fmarketplace_ci\u002Ffixtures\u002Fclaude\u002Fskills\u002Fexport-demo\u002FSKILL.md",[],[],{"skillNo":124,"name":125,"nameZh":6,"description":126,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":127,"categories":128,"keywords":129,"publishedAt":18},"01M79R042FS581DS2JNW5AZ1MK","work-to-development","Validate an accepted Linear Issue's readiness for implementation (criteria, dependencies, duplicate\u002Fexisting artifacts) and request governed branch\u002Fworktree creation through git-kit:starting-work — recording work-started Git\u002FGitHub evidence and a deliberate Linear Started transition only after Git identity is read back and verified. Use when asked to start work on a Linear issue, begin development for an accepted issue, or prepare an accepted issue for implementation. Never creates a branch directly — always delegates to git-kit.","https:\u002F\u002Fgithub.com\u002FAndreHahm\u002Fandres-cc-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fworkmanagement-kit\u002Fskills\u002Fwork-to-development\u002FSKILL.md",[],[],{"skillNo":131,"name":132,"nameZh":6,"description":133,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":134,"categories":135,"keywords":136,"publishedAt":18},"01M79QZZD4EHB82P72P4N92BKT","work-linking","Create and maintain stable cross-system links and authority labels between Notion and Linear records, and detect\u002Frepair drift between them. Use when asked to link a Notion record to a Linear record, check for drift between Notion and Linear, or repair a broken\u002Fstale link. Repairs only the bounded non-authoritative copy or link — never chooses by newest timestamp, and never creates a reverse-write loop against either system's own authority.","https:\u002F\u002Fgithub.com\u002FAndreHahm\u002Fandres-cc-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fworkmanagement-kit\u002Fskills\u002Fwork-linking\u002FSKILL.md",[],[],{"skillNo":138,"name":139,"nameZh":6,"description":140,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":141,"categories":142,"keywords":143,"publishedAt":18},"01M79QZVFA3GTVNZMJ51NESVSP","status-and-learning","Produce a dated, explicitly non-live Linear-to-Notion progress summary, or capture an outcome\u002Flearning after work completes. Use when asked to summarize progress to Notion, report portfolio status, or capture what was learned from a completed piece of work — not to disposition open follow-up items (see open-item-management for that). Never runs automatically or continuously — every summary is a deliberate, approved snapshot, not a live sync.","https:\u002F\u002Fgithub.com\u002FAndreHahm\u002Fandres-cc-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fworkmanagement-kit\u002Fskills\u002Fstatus-and-learning\u002FSKILL.md",[],[],{"skillNo":145,"name":146,"nameZh":6,"description":147,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":148,"categories":149,"keywords":150,"publishedAt":18},"01M79QZNSKSABK7X2PT93X8QT5","repository-gates","Discover, delegate, record, and invalidate this repository's actual Git\u002FGitHub lifecycle gates (pre-commit, pre-push, PR required checks, Codex delta review, review requirements, merge rights) and the repository-policy provider profile that maps governed operations to git-kit. Use when asked what gates apply to this repository, to discover repository policy before starting Wave 2 work, or to check whether prior gate evidence is still valid after new commits. Discovery and delegation only — never executes a gate's own internal logic, and never invents a gate the repository doesn't actually define (in particular, never assumes a \"Review Changes\" gate exists).","https:\u002F\u002Fgithub.com\u002FAndreHahm\u002Fandres-cc-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fworkmanagement-kit\u002Fskills\u002Frepository-gates\u002FSKILL.md",[],[]]