Skip to content
Back to skills

Forge Kb Optimize

ASecurity

Split this project's knowledge base: the core where the balance pays, topic files over their size limit; or tidy what the check found; a full careful pass on request. Plans first, writes only on approval, backs up, never commits.

  • 4 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 3, 2026
ai-agentsgobashnode

Works with

  • claude code

Security analysis

A100/100

Scanned December 3, 2026

npx -y skills add JZO001/forge-agent-tree --skill forge-kb-optimize --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Forge Kb Optimize?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Forge Kb Optimize
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/jzo001-forge-kb-optimize/badge)](https://www.skillsdirectory.com/skills/jzo001-forge-kb-optimize)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: forge-kb-optimize
description: "Split this project's knowledge base: the core where the balance pays, topic files over their size limit; or tidy what the check found; a full careful pass on request. Plans first, writes only on approval, backs up, never commits."
argument-hint: "[plan [topic files] | write [numbers] | tidy | tidy full [go] | tidy write [numbers]]"
allowed-tools: Read, Grep, Glob, Bash(node:*), Edit(./AI/.kb/**)
---

# Knowledge base optimizer

Optimize the knowledge base of the project in the working directory: the instruction files Claude Code loads into every session (`CLAUDE.md` and its `@` imports, or `AGENTS.md` alone) and the topic files they name. You never edit them yourself: you write your answer under `AI/.kb/`, and the script moves or edits the text, only in a `write` step the user asked for, after a backup, with a machine check that undoes the write on a miss.

Arguments: `$ARGUMENTS`. None or `plan`: plan a split of the core (with its balance) and of the topic files over their size limit. `plan` and topic files: plan only those, also one kept whole earlier. `write`: the user approved the last plan (all of it, or the numbers given). `tidy`: propose edits for the last check's findings. `tidy full`: a careful pass over every line of every file, on request only; `tidy full go` confirms it where the script stopped for the estimate. `tidy write`: the user approved the last list of edits (all of them, or the numbers given).

The script, KB below: `node "${CLAUDE_SKILL_DIR}/../../scripts/kb.mjs"`. If that path does not exist, find `scripts/kb.mjs` of the forge-agent-tree plugin with Glob. Run no command but the script, with the Bash tool, and run it alone: nothing chained before or after it. If `node` is missing or the script says Node is too old, tell the user why and stop: the optimizer has no mode without Node.

## plan (the default)

1. Run `KB optimize plan .`, with `--file <path>` for each topic file named after `plan`. If it says there is nothing to split, or there is no knowledge base, tell the user in a line (with the next step it names) and stop.
2. Do what the printed task asks, and write the one JSON object it describes with the Write tool to `AI/.kb/optimize-answer.json`. Judge each task of the sample honestly: a file you would not read before that task is not in its `reads`. For a topic file over its size limit, work from its outline; read a part of it only where a heading does not say enough.
3. Run `KB optimize plan . --answer AI/.kb/optimize-answer.json`. If it names errors in the answer's form, fix them, write the file again and run it again, once.
4. Tell the user in their language, briefly: the numbered list of what it splits (the core with its estimated net saving; each topic file before and after, its new files with their triggers, the sentence the core's map gains; the files kept whole and why), and the report's path. With "split it": they approve by running this skill again with `write`, or `write` and the numbers to keep. This skill's permissions hold only in the turn it runs in, so a plain "yes" is not enough here.

## write

Run `KB optimize write .`, with `--keep <numbers>` when the user named the plan's items to keep (for example `--keep 2,4`). It writes only the last plan, and only if the knowledge base has not changed since; it backs up, moves the text word for word (a moved section's heading stays with a pointer to its new file), checks every line and undoes the write on a miss; a file kept whole is recorded, and so is what a split leaves over the limit with its reason (`wholeAfter`) and a split the user left out of the numbers. Tell the user what it says: the files before and after, the references that still reach a moved section through its old place (the next tidy offers to point them at the new file), the files outside the knowledge base to check by hand, and the next step (a check on the new layout). Do not commit.

## tidy

1. Run `KB optimize tidy .`. If it says there is no check, the check is older than the knowledge base, or there is nothing to tidy, tell the user and stop.
2. Do what the printed task asks: read the files around each finding, and write the edits as the JSON it describes to `AI/.kb/tidy-answer.json`. A contradiction goes to `contradictions`, never into an edit. A person's decision and a "won't do" line are never removed or reworded. A repeat or stale text you leave as it is on purpose goes to `kept`, with its number and why: once approved, the check stops counting it.
3. Run `KB optimize tidy . --answer AI/.kb/tidy-answer.json`; on form errors, fix them and run it again, once.
4. Tell the user the numbered list in brief (what each edit changes, where, why), the findings kept as they are and why, the contradictions for them to decide, and how to approve: run this skill again with `tidy write` and the numbers to keep (none: all).

## tidy full

1. Run `KB optimize tidy-full .` (with `--go` for `tidy full go`). If it stops with an estimate, tell the user the size and the estimated cost, and that `tidy full go` (or ► go on the knowledge base page) runs it; stop there.
2. Otherwise it prints the files and one task. For each file, start a subagent of its own with that task, `<FILE>` replaced by the file's path, and ask it to answer with the JSON alone; up to five at a time. Check each answer's form yourself.
3. Merge their `edits` and `contradictions` into one object and write it to `AI/.kb/tidy-answer.json`, then run `KB optimize tidy . --answer AI/.kb/tidy-answer.json --full`.
4. Tell the user as for `tidy`, step 4: the list, the contradictions, the size before and after, and how to approve. Say that a full pass is worth it rarely: after a large rework, not on a knowledge base kept up by hand.

## tidy write

Run `KB optimize tidy-write .`, with `--keep <numbers>` when the user named the edits to keep (for example `--keep 1,3,4`). It writes only the last list, and only if the knowledge base has not changed since; it backs up, applies the edits, replays the log and undoes the write on a miss, and records the findings kept as they are in `AI/.kb/kept.json`. Tell the user what it says: the edits applied, the findings recorded as kept, the change log's path, and the guard's notes. Do not commit.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.