$npx -y skills add HKUST-KnowComp/DeepRefine-Skill --skill claude_skillClaude Code adapter for the DeepRefine agent-native refinement loop. Use when the user invokes /deeprefine, or asks to refine, diagnose, review, or apply changes to a Graphify / LLM-Wiki knowledge graph. Must follow the canonical DeepRefine skill rules and stop for review before
| 1 | # DeepRefine - Claude Code Adapter |
| 2 | |
| 3 | This file is the Claude Code-specific entrypoint. It keeps the platform rules |
| 4 | small and loads longer DeepRefine procedure details only when needed: |
| 5 | |
| 6 | - Full workflow, queue selection, refinement branch logic, and review rules: |
| 7 | [references/deeprefine-workflow.md](references/deeprefine-workflow.md) |
| 8 | - Verbatim judgement, abduction, and refinement prompts: |
| 9 | [references/llm-prompts.md](references/llm-prompts.md) |
| 10 | - Checklist, command sequence, trace schema, paths, and CLI mode: |
| 11 | [references/trace-and-commands.md](references/trace-and-commands.md) |
| 12 | |
| 13 | Do not reimplement or shorten the algorithm from memory. Load the relevant |
| 14 | reference file before executing that part of the workflow. |
| 15 | |
| 16 | ## Claude Code Invocation |
| 17 | |
| 18 | Trigger this skill when the user: |
| 19 | |
| 20 | - explicitly invokes `/deeprefine`; |
| 21 | - asks to refine, improve, diagnose, repair, inspect, or review a Graphify |
| 22 | knowledge graph; |
| 23 | - asks to apply a previously reviewed DeepRefine refinement. |
| 24 | |
| 25 | Run from the knowledge-base project root, where `graphify-out/graph.json` |
| 26 | exists. If the user is planning or asking how DeepRefine works, explain the |
| 27 | workflow and do not mutate files. |
| 28 | |
| 29 | If `deeprefine` is unavailable, tell the user to install it: |
| 30 | |
| 31 | ```bash |
| 32 | pip install deeprefine-cli |
| 33 | ``` |
| 34 | |
| 35 | For source development: |
| 36 | |
| 37 | ```bash |
| 38 | pip install -e /path/to/DeepRefine-Skill |
| 39 | ``` |
| 40 | |
| 41 | ## Hard Safety Policy |
| 42 | |
| 43 | A normal `/deeprefine` invocation is dry-run only and **MUST NEVER** call |
| 44 | `deeprefine apply`. |
| 45 | |
| 46 | The default workflow must stop after: |
| 47 | |
| 48 | 1. `deeprefine loop validate` |
| 49 | 2. `deeprefine review` |
| 50 | 3. showing the proposed actions and HIGH/MEDIUM/LOW review report to the user |
| 51 | |
| 52 | Then ask for explicit approval. |
| 53 | |
| 54 | Only if the user's next message explicitly says to approve/apply/write the graph |
| 55 | may you run: |
| 56 | |
| 57 | ```bash |
| 58 | deeprefine apply --trace-file ... --refinement-file ... |
| 59 | deeprefine loop finish --trace-file ... --refinement-file ... |
| 60 | ``` |
| 61 | |
| 62 | Do not treat any of these as approval: |
| 63 | |
| 64 | - generation of a `<refinement>` block; |
| 65 | - a valid `loop_trace_<query_id>.json`; |
| 66 | - a prior user message; |
| 67 | - a successful `deeprefine review`. |
| 68 | |
| 69 | If the review contains LOW-confidence actions, use |
| 70 | `--allow-low-confidence` only when the user's current approval message |
| 71 | explicitly accepts that risk. |
| 72 | |
| 73 | ## Mode Selection |
| 74 | |
| 75 | ### Full workflow |
| 76 | |
| 77 | Use for `/deeprefine`, or requests to refine/improve/fix the graph. |
| 78 | |
| 79 | Follow the canonical reference in this order: |
| 80 | |
| 81 | 1. `references/deeprefine-workflow.md` |
| 82 | 2. `references/llm-prompts.md` when producing tagged LLM outputs |
| 83 | 3. `references/trace-and-commands.md` when writing traces or running commands |
| 84 | |
| 85 | Do not copy only the latest query if pending history exists. Process all |
| 86 | unrefined history queries first, preserving canonical dedupe/order rules. |
| 87 | |
| 88 | ### Review only |
| 89 | |
| 90 | Use when the user asks to review, audit, inspect, dry-run, check evidence, or |
| 91 | show what would change. |
| 92 | |
| 93 | Run validation and review only: |
| 94 | |
| 95 | ```bash |
| 96 | deeprefine loop validate --trace-file ... --refinement-file ... |
| 97 | deeprefine review --trace-file ... --refinement-file ... |
| 98 | ``` |
| 99 | |
| 100 | Show the HIGH/MEDIUM/LOW evidence report. Do not modify `graph.json`. |
| 101 | |
| 102 | ### Apply only |
| 103 | |
| 104 | Use only when the user's current message explicitly approves a previously |
| 105 | reviewed refinement. |
| 106 | |
| 107 | Before applying, verify that the trace and refinement file match |
| 108 | `references/trace-and-commands.md` and the review rules in |
| 109 | `references/deeprefine-workflow.md`. Then run: |
| 110 | |
| 111 | ```bash |
| 112 | deeprefine loop validate --trace-file ... --refinement-file ... |
| 113 | deeprefine apply --trace-file ... --refinement-file ... |
| 114 | deeprefine loop finish --trace-file ... --refinement-file ... |
| 115 | ``` |
| 116 | |
| 117 | Use the LOW-confidence override only with explicit risk acknowledgement in the |
| 118 | same user message: |
| 119 | |
| 120 | ```bash |
| 121 | deeprefine apply --allow-low-confidence --trace-file ... --refinement-file ... |
| 122 | ``` |
| 123 | |
| 124 | ## Non-Negotiable Rules |
| 125 | |
| 126 | These are restated here so Claude always sees the hard stops before loading any |
| 127 | reference. |
| 128 | |
| 129 | Do not: |
| 130 | |
| 131 | 1. Run `deeprefine refine` unless the user explicitly asks for CLI/FAISS mode. |
| 132 | 2. Call `deeprefine apply` without a valid `loop_trace_<query_id>.json`. |
| 133 | 3. Call `deeprefine apply` before `deeprefine review` and explicit approval. |
| 134 | 4. Ignore LOW-confidence review warnings without explicit risk acceptance. |
| 135 | 5. Skip any hop's `<judge>Yes</judge>` / `<judge>No</judge>` judgement. |
| 136 | 6. Skip error abduction when `len(interaction_history) > 1`. |
| 137 | 7. Write `<refinement>` before abduction when refinement is required. |
| 138 | 8. Hand-edit `graphify-out/graph.json` with Python or ad-hoc JSON patches. |
| 139 | 9. Ignore pending history and refine only one latest query. |
| 140 | 10. Invent a shorter pipeline such as "read file -> write refinemen |