Skip to content
Back to search

sublinear-time-solver

Rust + WASM sublinear-time solver for asymmetric diagonally dominant systems. Exposes Neumann series, push, and hybrid random-walk algorithms with npm/npx CLI and Flow-Nexus HTTP streaming for swarm cost propagation and verification.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today

Check it deeper on your machine

It has changed since its scan on 11 Nov 2026.

As a Claude Code plugin, install it and then ask Claude Code:

/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/ruvnet/sublinear-time-solver with scanskillsafety

Or from a terminal, clone it and run it:

git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/ruvnet/sublinear-time-solver'

It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.

Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/ruvnet--sublinear-time-solver/badge.svg)](/listings/ruvnet--sublinear-time-solver)

HTML

<a href="/listings/ruvnet--sublinear-time-solver"><img src="/api/listings/ruvnet--sublinear-time-solver/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

Install

# Serve the solver as an MCP tool - no installation required!
npx sublinear-time-solver mcp
# Or use the serve alias
npx sublinear-time-solver serve

Direct CLI Usage

# Generate a diagonally dominant test matrix (1000x1000)
npx sublinear-time-solver generate -t diagonally-dominant -s 1000 -o matrix.json

# Create a matching vector of size 1000
node -e "console.log(JSON.stringify(Array(1000).fill(1)))" > vector.json

# Solve the linear system
npx sublinear-time-solver solve -m matrix.json -b vector.json -o solution.json

# Analyze matrix properties (condition number, diagonal dominance, etc.)
npx sublinear-time-solver analyze -m matrix.json --full

# Compare different solver methods
npx sublinear-time-solver solve -m matrix.json -b vector.json --method neumann
npx sublinear-time-solver solve -m matrix.json -b vector.json --method forward-push
npx sublinear-time-solver solve -m matrix.json -b vector.json --method random-walk

# Show usage examples
npx sublinear-time-solver help-examples

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 238 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. <a href="https://github.com/ruvnet/sublinear-time-solver"><img src="docs/assets/solver-hero.svg" alt="A sparse matrix with a small neighborhood highlighted. The solver can focus on the entries that matter." width="100%"></a>
  2. # Sublinear Time Solver: sparse linear solvers, PageRank and local push for JavaScript, MCP and Rust
  3. [![npm version](https://img.shields.io/npm/v/sublinear-time-solver.svg)](https://www.npmjs.com/package/sublinear-time-solver)
  4. [![npm downloads](https://img.shields.io/npm/dm/sublinear-time-solver.svg)](https://www.npmjs.com/package/sublinear-time-solver)
  5. [![Rust crate](https://img.shields.io/crates/v/sublinear.svg)](https://crates.io/crates/sublinear)
  6. [![core](https://img.shields.io/npm/v/@ruvnet/sublinear-core.svg?label=%40ruvnet%2Fsublinear-core)](https://www.npmjs.com/package/@ruvnet/sublinear-core)
  7. Solve systems of equations, estimate individual values, and rank nodes in a graph. Use the command line, the JavaScript API, the Rust crate, or an MCP client.
  8. The idea is simple. If a problem has many variables but each one depends on only a few others, the solver can sometimes answer a question by visiting a small neighborhood. Think of a sensor network where one reading changes and you want to check nearby readings first.
  9. [Quick start](#quick-start) · [How it works](#how-it-works) · [MCP](#use-it-with-an-mcp-client) · [Library](#use-it-in-code) · [Benchmarks](#performance) · [Upgrading from 1.7](#upgrading-from-17)
  10. | Package | Use it for | Runtime deps | Clean install |
  11. | --- | --- | --- | --- |
  12. | [`@ruvnet/sublinear-core`](packages/sublinear-core) | Embedding solvers and PageRank in a library or app | 0 | 1 package, 220 kB |
  13. | [`sublinear-time-solver`](https://www.npmjs.com/package/sublinear-time-solver) | MCP server, CLI, and the 1.x `SublinearSolver` class | 4 | 99 packages, 31 MB (1.7.2: 220 packages, 123 MB) |
  14. | [`sublinear`](https://crates.io/crates/sublinear) | Rust solvers with a complexity-typed API | — | `cargo add sublinear` |
  15. ## Quick start
  16. With Node.js and npm, paste this into a terminal in a scratch directory. The matrix uses coordinate format (COO), which lists the value, row, and column of each nonzero entry.
  17. ```bash
  18. cat > matrix.json <<'JSON'
  19. {
  20. "rows": 2, "cols": 2, "format": "coo",
  21. "values": [4, -1, -1, 4],
  22. "rowIndices": [0, 0, 1, 1],
  23. "colIndices": [0, 1, 0, 1]
  24. }
  25. JSON
  26. printf '%s\n' '[3,3]' > vector.json
  27. npx -y sublinear-time-solver solve --matrix matrix.json --vector vector.json \
  28. --method forward-push --output solution.json
  29. cat solution.json
  30. ```
  31. The two values in `solution` should be close to `[1, 1]`, and `metadata.converged` should be `true`. Run `npx -y sublinear-time-solver --help` to see commands for inspecting matrices, generating test inputs, and running PageRank.
  32. ## How it works
  33. ![A changed row lights up, the solver follows its nearby dependencies, and the highlighted entries become a small set of updates.](docs/assets/local-update.svg)
  34. A sparse matrix stores only the relationships that exist. A local solve starts with the row you care about, follows nearby dependencies, and returns a value or a small set of updates. The cost depends on how large that neighborhood gets and how much accuracy you need. A full solve returns every value, so its output grows with the size of the system.
  35. | If you need | Start with |
  36. | --- | --- |
  37. | Every value in a system of equations | CLI or MCP `solve` |
  38. | An estimate for one entry | MCP `estimateEntry` |
  39. | A small set of updates after a local change | The [Rust event driven example](examples/event_driven_anomaly.rs) on the development branch |
  40. | An importance score for each node in a graph | CLI `pagerank` or MCP `pageRank` |
  41. The local path works best when rows have few neighbors, the diagonal terms dominate, and the change stays local. Inspect your matrix with `analyze` and check the residual when you need to know how closely a solution satisfies the equations.
  42. ## Use it with an MCP client
  43. Add this to your client's MCP server configuration. It starts the server over standard input and output.
  44. ```json
  45. {
  46. "mcpServers": {
  47. "sublinear-solver": {
  48. "command": "npx",
  49. "args": ["-y", "sublinear-time-solver", "serve"]
  50. }
  51. }
  52. }
  53. ```
  54. With Claude Code: `claude mcp add sublinear -- npx -y sublinear-time-solver serve`. With Codex, add `[mcp_servers.sublinear]` with `command = "npx"` and `args = ["-y", "sublinear-time-solver", "serve"]` to `~/.codex/config.toml`. All diagnostics go to stderr, so stdout carries only JSON-RPC.
  55. Try asking your client to list the solver tools, then pass the COO matrix and vector from the quick start to `solve`. Clients can also inspect complexity metadata before choosing a tool. The [MCP server source](src/mcp/server.ts) has the tool schemas, and [ADR 001](docs/adr/ADR-001-complexity-as-architecture.md) explains the complexity budget.
  56. ## Use it in code
  57. The zero-dependency core is the fastest way to embed the math:
  58. ```bash
  59. npm install @ruvnet/sublinear-core
  60. ```
  61. ```js
  62. import { solve, graphFromEdges, pageRank, personalizedPageRank, forwardPush, topK } from '@ruvnet/sublinear-core';
  63. // A x = b. COO input; duplicate entries are summed. The residual is recomputed from x.
  64. const { x, residual, converged } = solve(
  65. { rows: 2, cols: 2, rowIndices: [0, 0, 1, 1], colIndices: [0, 1, 0, 1], values: [4, -1, -1, 4] },
  66. [3, 3],
  67. );
  68. // PageRank and personalized PageRank on string ids
  69. const g = graphFromEdges([['a', 'b'], ['b', 'c', 2], ['c', 'a'], ['a', 'c']]);
  70. topK(pageRank(g).scores, 3, g);
  71. personalizedPageRank(g, 'a', { damping: 0.85 });
  72. // Local top-k: the work depends on epsilon, not on the graph size
  73. topK(forwardPush(g, 'a', { epsilon: 1e-6 }).scores, 10, g);
  74. ```
  75. - **`solve(A, b, { method })`** accepts COO, dense rows, or a `CsrMatrix` (`csrFromCoo`, `csrFromDense`).
  76. - The default `'auto'` uses conjugate gradient for symmetric matrices with a positive diagonal and Gauss-Seidel otherwise.
  77. - `'jacobi'` and `'neumann'` are also available. The two have identical iterates.
  78. - Jacobi, Neumann and Gauss-Seidel need diagonal dominance. Conjugate gradient needs a symmetric positive definite matrix.
  79. - **`pageRank` / `personalizedPageRank`**: scores sum to 1. `damping` is the probability of following an edge, so a restart probability α means `damping = 1 − α`.
  80. - **`forwardPush(g, seeds, { epsilon })` / `backwardPush(g, target)`**: local personalized PageRank. Forward push does at most 1/((1 − damping)·epsilon) pushes, whatever the graph size.
  81. - **`estimateEntry(A, b, i, { walks })`**: estimates one entry of x by random walks and returns a standard error. After a one-time check per matrix, the cost does not depend on n.
  82. The [core package README](packages/sublinear-core/README.md) has the full API. `sublinear-time-solver/core` exposes the same functions plus the 1.x `SublinearSolver` class, without loading the MCP server. For Rust, run `cargo add sublinear` and see the [crate documentation](https://docs.rs/sublinear/).
  83. ### Use it from agentdb, claude-flow or ruvector
  84. Make `@ruvnet/sublinear-core` an optional dependency and keep your own fallback (`try { core = await import('@ruvnet/sublinear-core') } catch {}`).
  85. - **claude-flow**: replace `simplePersonalizedPageRank` with `personalizedPageRank(graphFromEdges(edges), seed, { damping: 1 - restart })` and `topK(scores, k, graph)`. claude-flow's `damping` is the restart probability.
  86. - **agentdb**: `SparsificationService` can use `personalizedPageRank(graphFromAdjacency(edges), source, { damping: 1 - alpha })`, or `forwardPush` for large graphs.
  87. - **ruvector**: rank similarity or code graphs with `pageRank`, or smooth signals over them by solving `(I + L) x = y` with `solve`.
  88. Runnable versions are in [`packages/sublinear-core/examples/`](packages/sublinear-core/examples).
  89. ## Performance
  90. ### Rust crate
  91. ![In one sparse matrix benchmark, the full solve took 66.7 microseconds at 256 rows and 258 microseconds at 1,024 rows. The local update took 2.28 and 2.32 milliseconds, respectively.](docs/assets/benchmark-scaling.svg)
  92. On this benchmark, quadrupling the number of rows took the full solve from **66.7 µs to 258 µs** and the local update from **2.28 ms to 2.32 ms**. The full solve was faster at both sizes. The local update grew more slowly because the changed neighborhood stayed small. See the [benchmark setup and results](BENCHMARK.md).
  93. ### JavaScript core
  94. **Setup.**
  95. - **Harness:** [`packages/sublinear-core/bench/bench.mjs`](packages/sublinear-core/bench/bench.mjs). Reproduce with `npm run bench`. Add `LEGACY=<dir>` to time sublinear-time-solver 1.7.2, and `GRAPH_TRANSFORMER=<dir>` to time `@ruvector/graph-transformer`.
  96. - **Inputs:** generated from fixed seeds. Linear systems are random sparse strictly diagonally dominant matrices with about 9 non-zeros per row.
  97. - **Machine:** Node v22.23.2 on an AMD Ryzen 9 9950X, single-threaded. The machine was shared (load average about 30), so treat the numbers as indicative.
  98. - **Timing:** best of 3 runs, except single runs at n = 1,000,000.
  99. **Linear solves: accuracy against dense Gaussian elimination (n = 1,000, tolerance 1e-12).**
  100. | Method | Time | Iterations | Relative residual | Max error vs dense |
  101. | --- | ---: | ---: | ---: | ---: |
  102. | Dense Gaussian elimination (reference) | 108.7 ms | — | — | — |
  103. | core `gauss-seidel` | 0.95 ms | 13 | 7.0e-13 | 4.0e-13 |
  104. | core `jacobi` | 2.04 ms | 20 | 2.5e-13 | 7.9e-14 |
  105. | core `neumann` | 0.70 ms | 20 | 2.5e-13 | 7.9e-14 |
  106. | 1.7.2 `SublinearSolver` neumann | 50.8 ms | 23 | **5.0e-1** | **1.3e-1** |
  107. The 1.7.2 Neumann solver returned a wrong answer here because its series used the wrong sign. That is fixed in 1.8.0.
  108. **Linear solves: scaling (tolerance 1e-10).**
  109. | n | nnz | Build CSR | Gauss-Seidel | Jacobi | 1.7.2 Neumann |
  110. | ---: | ---: | ---: | ---: | ---: | ---: |
  111. | 10,000 | 90 k | 8.8 ms | 2.3 ms (11 iterations) | 1.5 ms (16 iterations) | 4,402 ms |
  112. | 100,000 | 900 k | 70 ms | 32 ms | 43 ms | — |
  113. | 1,000,000 | 9.0 M | 951 ms | 474 ms | 314 ms | — |
  114. Full-vector solves cost time linear in nnz per iteration; they are not sublinear.
  115. **Personalized PageRank head to head.**
  116. - **Graphs:** unweighted, about 10 out-edges per node, no dangling nodes, so every implementation's conventions agree. Restart probability 0.15.
  117. - **Error:** max absolute error against a power iteration run to 1e-14.
  118. - **Timing:** core times exclude the one-time graph build. That build took 5.3 ms, 393 ms and 3.4 s at the three sizes. `pprScores` converts its adjacency-list input on every call, and that conversion is included in its time.
  119. | n (edges) | core `personalizedPageRank` to 1e-9 | core, fixed 20 iterations | `@ruvector/graph-transformer` `pprScores` (native, 20 iterations) | core `forwardPush` eps 1e-4 | core `forwardPush` eps 1e-7 | 1.7.2 `computePageRank` |
  120. | --- | --- | --- | --- | --- | --- | --- |
  121. | 1 k (10 k) | 0.34 ms, err 4e-12 | 0.21 ms, err 2.4e-10 | 0.52 ms, err 2.4e-10 | 0.08 ms, err 8.8e-3 | 1.4 ms, err 1.0e-5 | 3,439 ms, err 0.82, scores sum to 0.54 |
  122. | 100 k (1.0 M) | 46 ms, err 2e-13 | 33 ms, err 9.3e-11 | 85 ms, err 9.3e-11 | 0.20 ms, err 1.6e-3 | 187 ms, err 1.2e-4 | — |
  123. | 1 M (10 M) | 1,502 ms, err 2e-13 | 783 ms, err 3.6e-10 | 1,506 ms, err 3.6e-10 | 0.16 ms, err 5.0e-4 | 331 ms, err 2.3e-4 | — |
  124. **Where each tool fits.**
  125. - **Many queries on one graph:** core power iteration reuses a prebuilt CSR graph. Here it matched `pprScores` exactly at equal iterations and was 1.9 to 2.6 times faster per query.
  126. - **One query on a fresh graph:** `pprScores` is faster. It needs no separate build step, and the core's graph build costs about as much as 4 to 25 fixed-iteration queries.
  127. - **Large graphs, top-k only:** `forwardPush` touches only the neighbourhood of the seed. It answered in under 0.4 ms at every size, with per-node error near `epsilon × degree`. The top-ranked nodes stay accurate; small scores do not.
  128. - **Every score needed precisely:** run power iteration. A small `epsilon` makes push slower than power iteration.
  129. **Global PageRank on skewed graphs with dangling nodes (tolerance 1e-9).**
  130. | Graph | Build | `pageRank` | `personalizedPageRank` | Map-of-arrays PPR baseline (same iterations) | `forwardPush` top-10 overlap |
  131. | --- | ---: | ---: | ---: | ---: | --- |
  132. | n = 100 k, m = 1 M | 141 ms | 53 ms (18 iterations) | 35 ms (22 iterations) | 3,475 ms (same scores to 3e-18) | 8/10 at eps 1e-4 (0.27 ms), 9/10 at eps 1e-6 (10.6 ms) |
  133. | n = 1 M, m = 10 M | 3.1 s | 562 ms (18 iterations) | 1.6 s (23 iterations) | — | 10/10 at eps 1e-4 (0.32 ms), 9/10 at eps 1e-6 (42 ms) |
  134. **Single-entry estimates.** `estimateEntry` with 2,000 walks took 0.70 ms, 0.65 ms and 0.05 ms at n = 1 k, 100 k and 1 M. The walk-step count stayed at about 3,540 throughout. These times exclude the one-time O(nnz) validation of each matrix.
  135. ## What "sublinear" means here
  136. The name refers to algorithms whose cost is bounded by the query, not by the problem size. That includes single-entry random-walk estimates, local forward and backward push, and the Rust crate's closure-restricted `solve_on_change_sublinear`. The benchmarks above show that property directly.
  137. Computing the full solution vector, or full PageRank, is linear in nnz per iteration. No algorithm can produce all n entries in less than n time.
  138. The `solveTrueSublinear` MCP tool is deprecated. Until 1.9.0 it ran a Johnson-Lindenstrauss projection solver that densified the matrix (O(n²) time and memory) and was accurate to about 1e-2. Since 1.10.0 it runs the same sparse solver as `solve` and keeps its old output shape. Call `solve` instead.
  139. ## MCP tools
  140. **Core:**
  141. - `solve`: verified iterative solve
  142. - `estimateEntry`
  143. - `analyzeMatrix`
  144. - `pageRank`
  145. - `verifySparseSolution`
  146. - `coherenceScore`
  147. - `closureIndices`
  148. - `solveOnChangeSublinear`
  149. - `contrastiveSolveOnChangeSublinear`
  150. - `estimateComplexityClass`
  151. - `generateTestVector`
  152. - `saveVectorToFile`: basename-only, confined to a state directory
  153. **Deprecated:**
  154. - `solveTrueSublinear`: alias of the `solve` solver since 1.10.0
  155. - `analyzeTrueSublinearMatrix`
  156. **Experimental research tools:** temporal-lead calculators, psycho-symbolic reasoning, domain management, consciousness and emergence simulations, and the nanosecond scheduler. They ship for compatibility and exploration. Their outputs are simulations, not validated scientific measurements.
  157. Every matrix argument is validated before a handler runs:
  158. - indices must be in-range integers. This blocks property-key injection such as a `"__proto__"` index.
  159. - values must be finite.
  160. - dimension, non-zero and dense-allocation limits apply (`MATRIX_LIMITS`).
  161. ## Upgrading from 1.7
  162. 1.8.0 is a drop-in upgrade. The old exports and subpaths still work. The behaviour changes:
  163. - **Neumann solves are now correct.** They return the solution of A x = b to the requested residual. 1.7.x could return vectors with large errors.
  164. - **Non-convergence is reported, not thrown.** `SublinearSolver.solve` returns `converged: false` instead of throwing, and `residual` is always the true ‖A x − b‖₂ of the returned vector.
  165. - **Push methods.** `forward-push`, `backward-push` and `bidirectional` use Gauss-Seidel for full linear solves, and the result's `method` field says so. Their 1.7.x implementations reported convergence at several percent error. For local PageRank push, use `forwardPush`/`backwardPush`.
  166. - **`random-walk`** returns a Monte Carlo solution instead of throwing.
  167. - **`computePageRank`** scores sum to 1: dangling-node mass is redistributed, and `personalized` vectors are normalized.
  168. - **Output streams.** Nothing is written to stdout on import or during solves, and the MCP server routes all logs to stderr. Set `SUBLINEAR_DEBUG=1` for solver diagnostics on stderr.
  169. - **MCP `solve`** always uses the verified solvers. Since 1.10.0 `solveTrueSublinear` does too; the projection solver is gone.
  170. ## More resources
  171. [Changelog and upgrade notes](CHANGELOG.md) · [Security policy](SECURITY.md) · [Issue tracker](https://github.com/ruvnet/sublinear-time-solver/issues) · [License](LICENSE)
  172. The repository also includes [temporal lead solving](crates/temporal-lead-solver/), a [nanosecond scheduler](https://crates.io/crates/nanosecond-scheduler), and experimental [reasoning](crates/psycho-symbolic-reasoner/) and [consciousness exploration](src/consciousness-explorer/) modules.
.claude/settings.json · Bundled script · 114 lines · 1 finding marked
  1. {
  2. "env": {
  3. "CLAUDE_FLOW_AUTO_COMMIT": "false",
  4. "CLAUDE_FLOW_AUTO_PUSH": "false",
  5. "CLAUDE_FLOW_HOOKS_ENABLED": "true",
  6. "CLAUDE_FLOW_TELEMETRY_ENABLED": "true",
  7. "CLAUDE_FLOW_REMOTE_EXECUTION": "true",
  8. "CLAUDE_FLOW_CHECKPOINTS_ENABLED": "true"
  9. },
  10. "permissions": {
  11. "allow": [
  12. "Bash(npx claude-flow *)",
  13. "Bash(npm run lint)",
  14. "Bash(npm run test:*)",
  15. "Bash(npm test *)",
  16. "Bash(git status)",
  17. "Bash(git diff *)",
  18. "Bash(git log *)",
  19. "Bash(git add *)",
  20. "Bash(git commit *)",
  21. "Bash(git push)",
  22. "Bash(git config *)",
  23. "Bash(git tag *)",
  24. "Bash(git branch *)",
  25. "Bash(git checkout *)",
  26. "Bash(git stash *)",
  27. "Bash(jq *)",
  28. "Bash(node *)",
  29. "Bash(which *)",
  30. "Bash(pwd)",
  31. "Bash(ls *)"
  32. ],
  33. "deny": [
  34. "Bash(rm -rf /)",
    • Dismissed after review: Runs `rm -rf` against a root or home-directory path
    • Line 34 on GitHub
  35. "Bash(curl * | bash)",
  36. "Bash(wget * | sh)",
  37. "Bash(eval *)"
  38. ]
  39. },
  40. "hooks": {
  41. "PreToolUse": [
  42. {
  43. "matcher": "Bash",
  44. "hooks": [
  45. {
  46. "type": "command",
  47. "command": "cat | jq -r '.tool_input.command // empty' | tr '\\n' '\\0' | xargs -0 -I {} npx claude-flow@alpha hooks pre-command --command '{}' --validate-safety true --prepare-resources true"
  48. }
  49. ]
  50. },
  51. {
  52. "matcher": "Write|Edit|MultiEdit",
  53. "hooks": [
  54. {
  55. "type": "command",
  56. "command": "cat | jq -r '.tool_input.file_path // .tool_input.path // empty' | tr '\\n' '\\0' | xargs -0 -I {} npx claude-flow@alpha hooks pre-edit --file '{}' --auto-assign-agents true --load-context true"
  57. }
  58. ]
  59. }
  60. ],
  61. "PostToolUse": [
  62. {
  63. "matcher": "Bash",
  64. "hooks": [
  65. {
  66. "type": "command",
  67. "command": "cat | jq -r '.tool_input.command // empty' | tr '\\n' '\\0' | xargs -0 -I {} npx claude-flow@alpha hooks post-command --command '{}' --track-metrics true --store-results true"
  68. }
  69. ]
  70. },
  71. {
  72. "matcher": "Write|Edit|MultiEdit",
  73. "hooks": [
  74. {
  75. "type": "command",
  76. "command": "cat | jq -r '.tool_input.file_path // .tool_input.path // empty' | tr '\\n' '\\0' | xargs -0 -I {} npx claude-flow@alpha hooks post-edit --file '{}' --format true --update-memory true"
  77. }
  78. ]
  79. }
  80. ],
  81. "PreCompact": [
  82. {
  83. "matcher": "manual",
  84. "hooks": [
  85. {
  86. "type": "command",
  87. "command": "/bin/bash -c 'INPUT=$(cat); CUSTOM=$(echo \"$INPUT\" | jq -r \".custom_instructions // \\\"\\\"\"); echo \"🔄 PreCompact Guidance:\"; echo \"📋 IMPORTANT: Review CLAUDE.md in project root for:\"; echo \" • 54 available agents and concurrent usage patterns\"; echo \" • Swarm coordination strategies (hierarchical, mesh, adaptive)\"; echo \" • SPARC methodology workflows with batchtools optimization\"; echo \" • Critical concurrent execution rules (GOLDEN RULE: 1 MESSAGE = ALL OPERATIONS)\"; if [ -n \"$CUSTOM\" ]; then echo \"🎯 Custom compact instructions: $CUSTOM\"; fi; echo \"✅ Ready for compact operation\"'"
  88. }
  89. ]
  90. },
  91. {
  92. "matcher": "auto",
  93. "hooks": [
  94. {
  95. "type": "command",
  96. "command": "/bin/bash -c 'echo \"🔄 Auto-Compact Guidance (Context Window Full):\"; echo \"📋 CRITICAL: Before compacting, ensure you understand:\"; echo \" • All 54 agents available in .claude/agents/ directory\"; echo \" • Concurrent execution patterns from CLAUDE.md\"; echo \" • Batchtools optimization for 300% performance gains\"; echo \" • Swarm coordination strategies for complex tasks\"; echo \"⚡ Apply GOLDEN RULE: Always batch operations in single messages\"; echo \"✅ Auto-compact proceeding with full agent context\"'"
  97. }
  98. ]
  99. }
  100. ],
  101. "Stop": [
  102. {
  103. "hooks": [
  104. {
  105. "type": "command",
  106. "command": "npx claude-flow@alpha hooks session-end --generate-summary true --persist-state true --export-metrics true"
  107. }
  108. ]
  109. }
  110. ]
  111. },
  112. "includeCoAuthoredBy": true,
  113. "enabledMcpjsonServers": ["claude-flow", "ruv-swarm"]
  114. }

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.