brewcode:grepai
npx machina-cli add skill kochetkov-ma/claude-brewcode/grepai --openclawgrepai Skill
<instructions>Environment: Ollama + bge-m3 | GOB storage | Java/Kotlin/JS/TS
Mode Detection
Step 1: Detect Mode (MANDATORY FIRST STEP)
EXECUTE using Bash tool — detect mode from skill arguments:
bash scripts/detect-mode.sh "$ARGUMENTS"
Use $ARGUMENTS directly - it contains the skill invocation arguments.
Output format:
ARGS: [arguments received]
MODE: [detected mode]
Use the MODE value and GOTO that section below.
Mode Reference
| Keyword in args | MODE |
|---|---|
| upgrade, апгрейд | upgrade |
| optimize, update, улучши, обнови | optimize |
| stop, halt, kill | stop |
| start, watch | start |
| status, doctor, check, health | status |
| setup, configure, init | setup |
| reindex, rebuild, refresh | reindex |
| (empty) + .grepai/ exists | start |
| (empty) + no .grepai/ | setup |
| (unrecognized text) | prompt |
Prerequisites: Run
/installfirst to install brew, ollama, grepai, etc.
Mode: setup
Full grepai installation and project setup.
Phase 1: Infrastructure Check
EXECUTE using Bash tool:
bash scripts/infra-check.sh && echo "✅ infra-check" || echo "❌ infra-check FAILED"
STOP if ❌ — install missing components before continuing.
Phase 2: MCP Configuration & Permissions
EXECUTE using Bash tool:
bash scripts/mcp-check.sh && echo "✅ mcp-check" || echo "❌ mcp-check FAILED"
This script configures MCP server and allowedTools permissions.
STOP if ❌ — fix MCP configuration before continuing.
Phase 3: Generate Config
SPAWN the bc-grepai-configurator agent using Task tool:
| Parameter | Value |
|---|---|
subagent_type | brewcode:bc-grepai-configurator |
prompt | Configure grepai for this project. Analyze all build files, test patterns, source structure. Generate optimal .grepai/config.yaml. |
model | opus |
Context:
BC_PLUGIN_ROOTis available in agent context (injected by pre-task.mjs hook).
WAIT for agent to complete before proceeding.
Phase 4: Initialize Index
EXECUTE using Bash tool:
bash scripts/init-index.sh && echo "✅ init-index" || echo "❌ init-index FAILED"
STOP if ❌ — check
.grepai/logs/grepai-watch.logfor errors.
⏳ Synchronous — Large projects (5k+ files) take 10-30+ min. Monitor:
tail -f .grepai/logs/grepai-watch.log
Phase 5: Create Rule
EXECUTE using Bash tool:
bash scripts/create-rule.sh && echo "✅ create-rule" || echo "❌ create-rule FAILED"
STOP if ❌ — manually create rule in
.claude/rules/.
Phase 6: Verification
EXECUTE using Bash tool:
bash scripts/verify.sh && echo "✅ verify" || echo "❌ verify FAILED"
Mode: status
EXECUTE using Bash tool:
bash scripts/status.sh && echo "✅ status" || echo "❌ status FAILED"
Mode: start
EXECUTE using Bash tool:
bash scripts/start.sh && echo "✅ start" || echo "❌ start FAILED"
Mode: stop
EXECUTE using Bash tool:
bash scripts/stop.sh && echo "✅ stop" || echo "❌ stop FAILED"
Mode: reindex
Full index rebuild: stop watch → clean → rebuild → restart.
EXECUTE using Bash tool:
bash scripts/reindex.sh && echo "✅ reindex" || echo "❌ reindex FAILED"
⏳ Synchronous — Monitor:
tail -f .grepai/logs/grepai-watch.log
Mode: optimize
Re-analyze project and regenerate config with backup.
Step 1: Backup current config
EXECUTE using Bash tool:
bash scripts/optimize.sh && echo "✅ optimize-backup" || echo "❌ optimize-backup FAILED"
STOP if ❌ — check if .grepai/config.yaml exists.
Step 2: Regenerate config
SPAWN the bc-grepai-configurator agent using Task tool:
| Parameter | Value |
|---|---|
subagent_type | brewcode:bc-grepai-configurator |
prompt | Re-analyze project and regenerate .grepai/config.yaml. Compare with existing config, optimize boost patterns, update trace languages. |
model | opus |
Context:
BC_PLUGIN_ROOTis available in agent context (injected by pre-task.mjs hook).
WAIT for agent to complete.
Step 3: Reindex with new config
EXECUTE using Bash tool:
bash scripts/reindex.sh && echo "✅ reindex" || echo "❌ reindex FAILED"
Mode: upgrade
Update grepai CLI via Homebrew.
EXECUTE using Bash tool:
bash scripts/upgrade.sh && echo "✅ upgrade" || echo "❌ upgrade FAILED"
Mode: prompt
Use AskUserQuestion to ask which operation to run:
header: "grepai"
question: "Which grepai operation do you want to run?"
options:
- label: "setup"
description: "Initialize and configure semantic search for this project"
- label: "status"
description: "Check health, index stats, doctor"
- label: "start / watch"
description: "Start watch mode (auto-index on file changes)"
- label: "optimize"
description: "Update and rebuild the search index"
For stop, reindex, upgrade — user types via Other. After answer, GOTO that mode section.
</instructions>Output Format
# grepai [MODE]
## Detection
| Field | Value |
|-------|-------|
| Arguments | `$ARGUMENTS` |
| Mode | `[detected mode]` |
## Status
| Component | Status |
|-----------|--------|
| grepai CLI | [✅/❌] |
| ollama | [✅/❌] |
| bge-m3 model | [✅/❌] |
| MCP | [✅/❌] |
| Permissions | [✅/❌] allowedTools |
| .grepai/ | [✅/❌] |
| index | [size/indexing] |
| watch | [running/stopped] |
| rule | [✅/⚠️] |
## Actions Taken
- [action 1]
- [action 2]
## Next Steps
- [if any issues, list resolution steps]
Source
git clone https://github.com/kochetkov-ma/claude-brewcode/blob/main/brewcode/skills/grepai/SKILL.mdView on GitHub Overview
grepai skill orchestrates the semantic search workflow for BrewCode projects. It handles setup, status checks, and lifecycle commands (start, stop, reindex, optimize, upgrade) to keep grepai running smoothly. This enables teams to deploy, maintain, and scale their semantic search with reliable automation.
How This Skill Works
It first detects the requested mode from arguments using a Bash script, then dispatches to the appropriate phase or script for that mode. Supported actions map to dedicated scripts (setup phases, status.sh, start.sh, stop.sh, reindex.sh, optimize.sh, and upgrade paths) to perform installation, monitoring, and configuration tasks within the Ollama + bge-m3 environment.
When to Use It
- Setting up grepai for a new BrewCode project.
- Checking the current status of the grepai service.
- Starting or stopping grepai during maintenance.
- Rebuilding the semantic index after major code changes.
- Upgrading or optimizing the grepai configuration to improve performance.
Quick Start
- Step 1: Detect mode from arguments with bash scripts/detect-mode.sh "$ARGUMENTS"
- Step 2: Run the corresponding mode (e.g., bash scripts/start.sh, bash scripts/status.sh, etc.)
- Step 3: Monitor logs and verify results, e.g., tail -f .grepai/logs/grepai-watch.log and/or status verification
Best Practices
- Run setup in a controlled environment and verify infra-check and MCP checks before proceeding.
- Review the generated .grepai/config.yaml and adjust MCP permissions.
- Monitor grepai-watch.log during long-running operations.
- Use reindex after large codebase changes to ensure search accuracy.
- Backup before optimize or upgrade and verify outcome with status afterward.
Example Use Cases
- Initialize grepai for a new repository with bc-grepai-configurator.
- Check status after deployment and confirm healthy state.
- Perform a full reindex after adding thousands of files.
- Run optimize to backup and regenerate config for a project.
- Upgrade grepai to a newer model with minimal downtime.