Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
233 changes: 233 additions & 0 deletions skills/agent-sort/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
---
name: agent-sort
description: >
Sort and install ECC for any project. Launches 6 parallel agents that read every
ECC item, search the actual codebase for evidence, and sort into DAILY vs LIBRARY.
Use when: "sort ECC", "set up ECC", "install ECC for this project", "cherry pick ECC",
"configure ECC skills", or when starting ECC setup on a new repo.
---

# Agent-Sort: Automated ECC Cherry-Picker

## Prerequisites

ECC must be cloned locally. Check these locations in order:
1. `~/ecc-reference/`
2. `/tmp/everything-claude-code/`
3. Ask the user for the path if neither exists.

## Step 1: Locate ECC

```bash
ECC_PATH=""
if [ -d ~/ecc-reference/agents ]; then ECC_PATH=~/ecc-reference
elif [ -d /tmp/everything-claude-code/agents ]; then ECC_PATH=/tmp/everything-claude-code
fi
```

If not found, tell the user:
```
ECC not found. Run: git clone https://github.com/affaan-m/everything-claude-code.git ~/ecc-reference
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Setup docs instruct cloning external source and installing executable hooks/scripts from it, creating a supply-chain trust bypass.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At skills/agent-sort/SKILL.md, line 30:

<comment>Setup docs instruct cloning external source and installing executable hooks/scripts from it, creating a supply-chain trust bypass.</comment>

<file context>
@@ -0,0 +1,233 @@
+
+If not found, tell the user:
+```
+ECC not found. Run: git clone https://github.com/affaan-m/everything-claude-code.git ~/ecc-reference
+```
+
</file context>
Fix with Cubic

```

## Step 2: Launch 6 Parallel Agents

Launch ALL 6 agents simultaneously using the Agent tool. Each agent reads every ECC item in its category and searches THIS repo for matching languages, frameworks, imports, and file types.

### Agent 1 — AGENTS (reads ~/ecc-reference/agents/*.md)

```
Read the first 20 lines of each agent .md file in {ECC_PATH}/agents/.
For each, search THIS repo for matching languages, frameworks, imports, file extensions.

Evidence checks:
- Glob("**/*.ts", "**/*.tsx") for TypeScript
- Glob("**/*.py") for Python
- Glob("**/*.go", "**/go.mod") for Go
- Glob("**/*.rs", "**/Cargo.toml") for Rust
- Check package.json for framework dependencies

Output format:
DAILY:
- agent-name.md | one-line evidence from repo

LIBRARY:
- agent-name.md | reason

SKIP:
- agent-name.md | reason
```

### Agent 2 — SKILLS (reads ~/ecc-reference/skills/*/SKILL.md)

```
Read the SKILL.md frontmatter (first 15 lines) in each {ECC_PATH}/skills/*/ folder.
For each, search THIS repo for matching patterns, dependencies, and file structure.

Output: DAILY / LIBRARY / SKIP with evidence.
```

### Agent 3 — COMMANDS (reads ~/ecc-reference/commands/*.md)

```
Read the first 15 lines of each {ECC_PATH}/commands/*.md.
- Language-specific commands (/go-review, /rust-build) → match to project languages
- General dev commands (/plan, /verify, /tdd) → DAILY for any project
- Meta-tool commands (/instinct-status, /evolve) → LIBRARY

Output: DAILY / LIBRARY / SKIP with evidence.
```

### Agent 4 — RULES (reads ~/ecc-reference/rules/**/*.md)

```
List all rule files in {ECC_PATH}/rules/ (all subdirectories).
Check this repo for matching languages:
- Glob("**/*.ts") → install rules/typescript/
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Rule installation logic is incomplete: Agent 4 only detects TypeScript and Python, so language-specific rules for other supported stacks are skipped.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At skills/agent-sort/SKILL.md, line 86:

<comment>Rule installation logic is incomplete: Agent 4 only detects TypeScript and Python, so language-specific rules for other supported stacks are skipped.</comment>

<file context>
@@ -0,0 +1,233 @@
+```
+List all rule files in {ECC_PATH}/rules/ (all subdirectories).
+Check this repo for matching languages:
+- Glob("**/*.ts") → install rules/typescript/
+- Glob("**/*.py") → install rules/python/
+- rules/common/ → always install
</file context>
Fix with Cubic

- Glob("**/*.py") → install rules/python/
- rules/common/ → always install

Check if .claude/rules/ already exists. Flag duplicates.

Output: INSTALL / SKIP per file.
```

### Agent 5 — HOOKS (reads ~/ecc-reference/hooks/)

```
Read {ECC_PATH}/hooks/hooks.json and {ECC_PATH}/hooks/README.md.
List all scripts in {ECC_PATH}/scripts/hooks/ and {ECC_PATH}/scripts/lib/.
Check this repo for:
- Prettier config (.prettierrc, prettier in package.json)
- TypeScript (tsconfig.json)
- ESLint config
- OS: flag tmux hooks on Windows, osascript hooks on non-macOS

Output: INSTALL / SKIP / NEEDS-ADAPTATION per item.
```

### Agent 6 — EXTRAS (contexts, guides, configs)

```
Read {ECC_PATH}/contexts/*.md → always DAILY (lightweight mode-switchers).
Check {ECC_PATH}/mcp-configs/, examples/, guides → LIBRARY-REFERENCE.
Check .agents/, docs/, tests/ → SKIP (ECC internals).

Output: DAILY / LIBRARY-REFERENCE / SKIP per item.
```

## Step 3: Compile Results

After all 6 agents return, combine results into a single sorted list:
- DAILY items (typically ~50)
- LIBRARY items (typically ~170)
- INSTALL rules (typically ~14 for one language)
- INSTALL hooks/scripts (typically ~40)

## Step 4: Install

### Create directory structure
```bash
mkdir -p .claude/skills/skill-library/references
mkdir -p .claude/rules
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Rule copy targets are referenced without creating required subdirectories, which can cause rule installation to fail.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At skills/agent-sort/SKILL.md, line 132:

<comment>Rule copy targets are referenced without creating required subdirectories, which can cause rule installation to fail.</comment>

<file context>
@@ -0,0 +1,233 @@
+### Create directory structure
+```bash
+mkdir -p .claude/skills/skill-library/references
+mkdir -p .claude/rules
+mkdir -p .claude/hooks
+mkdir -p .claude/scripts/hooks .claude/scripts/lib
</file context>
Fix with Cubic

mkdir -p .claude/hooks
mkdir -p .claude/scripts/hooks .claude/scripts/lib
```

### Copy DAILY items
```
Agents → .claude/skills/{name}/SKILL.md
Skills → .claude/skills/{name}/ (cp -r, keeps references/)
Commands → .claude/skills/cmd-{name}/SKILL.md
Contexts → .claude/skills/context-{name}/SKILL.md
```

### Copy LIBRARY items
```
All non-DAILY → .claude/skills/skill-library/references/{prefix}-{name}.md
Prefix: agent-, skill-, cmd- to avoid name collisions
```

### Create router
Create `.claude/skills/skill-library/SKILL.md` with a trigger table listing every library item with keywords that would activate it. This is the ONLY way Claude finds library items.
Comment on lines +151 to +152
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Specify the router SKILL.md format and structure.

Line 152 states that creating the router file is "the ONLY way Claude finds library items," but provides no details on its format, structure, or content. Users need:

  1. The exact frontmatter schema required
  2. The trigger table format (markdown table? list? YAML?)
  3. How to extract/generate keywords from library items
  4. A complete example of a valid router file

Would you like me to draft a specification or example for the router SKILL.md format?

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@skills/agent-sort/SKILL.md` around lines 151 - 152, Add a clear specification
for the router SKILL.md by updating the "Create router" section: define the
required frontmatter schema (e.g., title, id, description, version, author),
specify the trigger table format as a Markdown table with columns like "item_id
| keywords | description | path" and exact parsing rules, describe how to
extract/generate keywords from library items (suggest tokenization, stopword
removal, and manual overrides via a "keywords" field in each item), and include
a complete, concrete example SKILL.md that demonstrates frontmatter plus a
populated trigger table for multiple library items; reference the
".claude/skills/skill-library/SKILL.md" file and the "Create router" heading so
reviewers can find and validate the added schema and example.


### Copy rules
Only matching languages + common/:
```
{ECC_PATH}/rules/common/*.md → .claude/rules/common/
{ECC_PATH}/rules/{language}/*.md → .claude/rules/{language}/
```

### Copy hooks + scripts
```
{ECC_PATH}/hooks/hooks.json → .claude/hooks/
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Hooks configuration is copied unfiltered even though some hook scripts may be skipped/adaptation-required, which can leave hooks.json referencing unavailable or incompatible scripts.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At skills/agent-sort/SKILL.md, line 163:

<comment>Hooks configuration is copied unfiltered even though some hook scripts may be skipped/adaptation-required, which can leave `hooks.json` referencing unavailable or incompatible scripts.</comment>

<file context>
@@ -0,0 +1,233 @@
+
+### Copy hooks + scripts
+```
+{ECC_PATH}/hooks/hooks.json              → .claude/hooks/
+{ECC_PATH}/scripts/hooks/*.js            → .claude/scripts/hooks/
+{ECC_PATH}/scripts/lib/*.js              → .claude/scripts/lib/
</file context>
Fix with Cubic

{ECC_PATH}/scripts/hooks/*.js → .claude/scripts/hooks/
{ECC_PATH}/scripts/lib/*.js → .claude/scripts/lib/
{ECC_PATH}/scripts/setup-package-manager.js → .claude/scripts/
```

Skip any items marked NEEDS-ADAPTATION with a note to the user.

### Copy guides as references
```
{ECC_PATH}/the-shortform-guide.md → .claude/skills/skill-library/references/
{ECC_PATH}/the-longform-guide.md → .claude/skills/skill-library/references/
{ECC_PATH}/the-security-guide.md → .claude/skills/skill-library/references/
```

## Step 5: Verify

Check every item landed on disk:
```bash
# Count daily skills (exclude skill-library)
ls -d .claude/skills/*/ | grep -v skill-library | wc -l

# Count library references
ls .claude/skills/skill-library/references/ | wc -l

# Count rules
ls .claude/rules/**/*.md | wc -l
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Rule-count verification uses a non-portable/non-recursive glob pattern and can report incorrect totals.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At skills/agent-sort/SKILL.md, line 189:

<comment>Rule-count verification uses a non-portable/non-recursive glob pattern and can report incorrect totals.</comment>

<file context>
@@ -0,0 +1,233 @@
+ls .claude/skills/skill-library/references/ | wc -l
+
+# Count rules
+ls .claude/rules/**/*.md | wc -l
+
+# Verify hooks
</file context>
Fix with Cubic


# Verify hooks
test -f .claude/hooks/hooks.json && echo "✓" || echo "✗"

# Count scripts
ls .claude/scripts/hooks/ | wc -l
ls .claude/scripts/lib/ | wc -l
```
Comment on lines +181 to +197
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Fix shell commands to handle edge cases and ensure portability.

The verification commands have several issues:

  1. Line 183: ls -d .claude/skills/*/ will error if no directories exist
  2. Line 189: ls .claude/rules/**/*.md relies on bash globstar expansion which may not be enabled; use find instead
  3. Missing error handling throughout
🔧 Proposed fixes for robust verification
 # Count daily skills (exclude skill-library)
-ls -d .claude/skills/*/ | grep -v skill-library | wc -l
+find .claude/skills/ -mindepth 1 -maxdepth 1 -type d ! -name skill-library | wc -l

 # Count library references
-ls .claude/skills/skill-library/references/ | wc -l
+find .claude/skills/skill-library/references/ -type f 2>/dev/null | wc -l

 # Count rules
-ls .claude/rules/**/*.md | wc -l
+find .claude/rules/ -name "*.md" -type f | wc -l

 # Verify hooks
 test -f .claude/hooks/hooks.json && echo "✓" || echo "✗"

 # Count scripts
-ls .claude/scripts/hooks/ | wc -l
-ls .claude/scripts/lib/ | wc -l
+find .claude/scripts/hooks/ -type f 2>/dev/null | wc -l
+find .claude/scripts/lib/ -type f 2>/dev/null | wc -l
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@skills/agent-sort/SKILL.md` around lines 181 - 197, Replace fragile
ls/globstar usage with robust checks: for the skills count, ensure the
.claude/skills directory exists, list only immediate subdirectories and exclude
the "skill-library" entry (.claude/skills/*/), and return 0 if none exist; for
library references, ensure .claude/skills/skill-library/references exists and
count files there; for rules, stop using the globstar pattern
(.claude/rules/**/*.md) and use a recursive file search limited to *.md under
.claude/rules; for hooks keep the existing test for .claude/hooks/hooks.json but
explicitly check the directory exists and handle missing files gracefully; for
scripts ( .claude/scripts/hooks and .claude/scripts/lib ) ensure directories
exist before counting and return zero if empty — overall replace glob-dependent
commands with existence checks and recursive file searches so the checks are
portable and safe.


Print summary:
```
Daily skills: XX folders
Library refs: XX files
Router: ✓/✗
Rules: XX files (common + {language})
Hook scripts: XX files
Lib scripts: XX files
Total files: XX
Token cost: ~X,XXX always loaded
```

## Step 6: Clean up stale rules

If `.claude/rules/` has language directories for languages NOT found in the repo, remove them:
```bash
# Example: if no Python files exist
test $(find . -name "*.py" -not -path "./node_modules/*" | wc -l) -eq 0 && rm -rf .claude/rules/python/
```
Comment on lines +211 to +217
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Add safeguards to prevent unintended file deletion.

The cleanup command at line 216 has critical safety issues:

  1. If the find command fails, the test may behave unexpectedly
  2. No validation that the target path is within .claude/rules/
  3. No existence check before rm -rf
  4. No error handling or confirmation prompt
🛡️ Proposed safer implementation
 ## Step 6: Clean up stale rules

 If `.claude/rules/` has language directories for languages NOT found in the repo, remove them:
 ```bash
 # Example: if no Python files exist
-test $(find . -name "*.py" -not -path "./node_modules/*" | wc -l) -eq 0 && rm -rf .claude/rules/python/
+if [ -d .claude/rules/python/ ]; then
+  PY_COUNT=$(find . -name "*.py" -not -path "./node_modules/*" -not -path "./.claude/*" 2>/dev/null | wc -l)
+  if [ "$PY_COUNT" -eq 0 ]; then
+    echo "No Python files found, removing .claude/rules/python/"
+    rm -rf .claude/rules/python/
+  fi
+fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@skills/agent-sort/SKILL.md` around lines 211 - 217, Replace the unsafe
one-liner that conditionally runs rm -rf on .claude/rules/python/ with a guarded
sequence: first check the directory exists (".claude/rules/python/"), then run
the find command but exclude "./.claude/*" and "./node_modules/*" and redirect
errors to /dev/null to avoid find failures affecting the test, capture the file
count into a variable (e.g., PY_COUNT), and only call rm -rf if PY_COUNT equals
0; also echo a confirmation/log message before removal to make the action
explicit. Ensure the logic references the same path ".claude/rules/python/" and
that rm -rf is only executed after the directory existence and zero-count checks
succeeded.


## What stays the same across every project

These are always DAILY regardless of stack:
```
Agents: planner, architect, code-reviewer, security-reviewer,
build-error-resolver, refactor-cleaner, tdd-guide,
docs-lookup, doc-updater
Skills: coding-standards, tdd-workflow, security-review, security-scan,
continuous-learning, strategic-compact, verification-loop
Commands: learn, checkpoint, docs, aside, plan, verify, save-session,
resume-session, quality-gate, build-fix, code-review, refactor-clean
Contexts: dev, review, research
```

~35 items always daily. The remaining ~15 daily items come from matching the project's stack.
Comment on lines +1 to +233
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Restructure to include required sections: 'When to Use', 'How It Works', and 'Examples'.

The skill file must follow the standard format with clearly defined sections. Currently, the procedural steps are present but not organized according to the required structure. As per coding guidelines, skills must be formatted with clear sections including 'When to Use', 'How It Works', and 'Examples'.

Suggested structure:

  • When to Use: Extract trigger phrases from the frontmatter description and expand with use cases
  • How It Works: Convert Steps 1-6 into a narrative explanation of the workflow
  • Examples: Add at least one complete example showing the skill in action with expected output

</review_comment_end>

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@skills/agent-sort/SKILL.md` around lines 1 - 233, The SKILL.md must be
restructured to include the required top-level sections "When to Use", "How It
Works", and "Examples": extract the trigger phrases from the frontmatter
description into a concise "When to Use" list (include phrases like "sort ECC",
"set up ECC", "install ECC for this project", etc.), convert Steps 1–6 into a
narrative "How It Works" that explains locating ECC, launching 6 agents (Agents,
Skills, Commands, Rules, Hooks, Extras), compiling results, installing files,
and verification, and add an "Examples" section with at least one end-to-end
example showing a sample command/flow and the expected outputs (summary counts
and success checks) referencing the Step 5 verification commands so the example
demonstrates their expected results; update any inline procedural fragments to
follow prose sections rather than raw step headings.