From e5dbe95acbf0d422f09ed0f716f302379c7db919 Mon Sep 17 00:00:00 2001 From: Paul O'Reilly Date: Mon, 11 May 2026 21:43:29 +1200 Subject: [PATCH] Add /ask-minimax-with-context skill Walks CONTEXT.md and CLAUDE.md files from a given folder up to the git root, assembles them into a context bundle via shell redirects (file contents never enter the calling session), then delegates a one-line question to MiniMax M2.7. Token cost to the main session: paths only. Co-Authored-By: Claude Sonnet 4.6 --- MEMORY.md | 1 + memory/skill-ask-minimax-with-context.md | 35 +++++ skills/ask-minimax-with-context/SKILL.md | 170 +++++++++++++++++++++++ 3 files changed, 206 insertions(+) create mode 100644 memory/skill-ask-minimax-with-context.md create mode 100644 skills/ask-minimax-with-context/SKILL.md diff --git a/MEMORY.md b/MEMORY.md index 0eb2e00..f33661c 100644 --- a/MEMORY.md +++ b/MEMORY.md @@ -15,6 +15,7 @@ - [Process Lessons](memory/process-lessons.md) — Container agent workflow patterns, skill development rules - [Decisions](memory/decisions.md) — Task orchestration architecture decisions, harness design rationale +- [skill-ask-minimax-with-context](memory/skill-ask-minimax-with-context.md) — Walk CONTEXT.md+CLAUDE.md up to git root, bundle via shell redirects, delegate question to MiniMax ## Task Orchestration Skills (2026-03-24) diff --git a/memory/skill-ask-minimax-with-context.md b/memory/skill-ask-minimax-with-context.md new file mode 100644 index 0000000..936776f --- /dev/null +++ b/memory/skill-ask-minimax-with-context.md @@ -0,0 +1,35 @@ +# Skill: ask-minimax-with-context + +## Purpose + +Delegate a focused question to MiniMax M2.7 with automatically gathered project context, without loading any file contents into the current session. + +## Usage + +``` +/ask-minimax-with-context +``` + +Example: `/ask-minimax-with-context octopus/staging/ Has build 1.4.202 been deployed?` + +## How It Works + +1. Parses args: first token = folder path, rest = question +2. Walks from the given folder up to the git root collecting `CONTEXT.md` and `CLAUDE.md` at each level (deepest-first) +3. Assembles a context bundle at `/tmp/ask-minimax-ctx-.md` via shell redirects — file contents never enter the calling session's context +4. Writes a prompt file telling MiniMax to read the bundle and answer the question +5. Runs `ask-minimax-run` (MiniMax M2.7, read+write tools only) +6. Reads the result file and summarises concisely +7. Cleans up temp files (keeps result file) + +## When to Use + +- Any question where the answer lives in CONTEXT.md or CLAUDE.md files in a project tree +- Even simple questions — overhead is one line from the user, context savings are real +- Alternative to loading large context hierarchies into the main session just to answer a single question + +## Gotchas + +- Path must resolve to a directory that is inside a git repo (used to find the walk ceiling) +- If no CONTEXT.md or CLAUDE.md files are found, the skill warns and asks whether to proceed with the question only +- Requires the MiniMax profile at `~/.claude-oreillyit-minimax/provider.env` diff --git a/skills/ask-minimax-with-context/SKILL.md b/skills/ask-minimax-with-context/SKILL.md new file mode 100644 index 0000000..d686fbe --- /dev/null +++ b/skills/ask-minimax-with-context/SKILL.md @@ -0,0 +1,170 @@ +--- +name: ask-minimax-with-context +description: > + Walk CONTEXT.md and CLAUDE.md files from a folder up to the git root, assemble them into + a context bundle via shell redirects (contents never enter this session), then delegate a + one-line question to MiniMax. Saves context and Anthropic tokens even for simple questions. + Usage: /ask-minimax-with-context +user_invocable: true +allowed-tools: Read, Write, Bash(ask-minimax-run *), Bash(date *), Bash(rm -f *), Bash(test *), Bash(pwd), Bash(bash *) +--- + +ask-minimax-with-context + +# /ask-minimax-with-context Skill + +Walk `CONTEXT.md` and `CLAUDE.md` files from a given folder up to the git root. Assemble them into a context bundle via shell redirects — file contents never appear in this session. Then delegate a one-line question to MiniMax; only a concise answer flows back. + +**Usage:** `/ask-minimax-with-context ` + +**Example:** `/ask-minimax-with-context octopus/staging/ Has build 1.4.202 been deployed?` + +## Pre-gathered context + +### Current date +!`date +%Y-%m-%d` + +### Working directory +!`pwd` + +## Instructions + +### Step 0 — Verify profile readiness + +```bash +test -f ~/.claude-oreillyit-minimax/provider.env && echo "minimax profile: ready" || echo "minimax profile: MISSING" +``` + +If MISSING, tell the user the profile is not configured and stop. + +### Step 1 — Parse arguments + +From `$ARGUMENTS`: +- **Path**: the first whitespace-delimited token +- **Question**: everything after the first token + +If either is missing, tell the user the correct usage format and stop. + +### Step 2 — Generate a timestamp + +```bash +date +%s +``` + +Note the integer as `TS`. Use it as a suffix on all temp files. + +### Step 3 — Walk the tree and assemble the context bundle + +Run the following bash script, substituting the literal values of `PATH_ARG` (from Step 1) and `TS` (from Step 2) before executing. Do not use shell variables as placeholders — write the actual values inline. + +The script resolves the path to absolute, walks up to the git root collecting `CONTEXT.md` and `CLAUDE.md` at each level (deepest first), and shell-redirects each file into the bundle. File contents never appear in stdout — only a summary line is returned. + +```bash +bash -c ' +set -e +path="PATH_ARG" +ts="TS" +bundle="/tmp/ask-minimax-ctx-${ts}.md" + +# Resolve to absolute path +case "$path" in + /*) ;; + *) path="$(pwd)/$path" ;; +esac +path="${path%/}" + +# Find git root (stop walking here) +git_root=$(git -C "$path" rev-parse --show-toplevel 2>/dev/null || echo "") +[ -z "$git_root" ] && git_root="/" + +# Walk from given dir up to git root +dir="$path" +count=0 +while true; do + for fname in CONTEXT.md CLAUDE.md; do + fpath="$dir/$fname" + if [ -f "$fpath" ]; then + echo "## Context from: $fpath" >> "$bundle" + echo "" >> "$bundle" + cat "$fpath" >> "$bundle" + echo "" >> "$bundle" + echo "---" >> "$bundle" + echo "" >> "$bundle" + count=$((count + 1)) + fi + done + [ "$dir" = "$git_root" ] && break + parent=$(dirname "$dir") + [ "$parent" = "$dir" ] && break + dir="$parent" +done + +echo "Bundle assembled: $bundle ($count files)" +' +``` + +If the output says `(0 files)`, warn the user that no context files were found and ask whether to proceed with the question only. + +### Step 4 — Write the prompt file + +Use the Write tool to create `/tmp/ask-minimax-TS-prompt.txt` (replace `TS` with the actual timestamp integer). Fill in all values — no placeholders in the written file. + +``` +You are running in non-interactive (-p) mode. Read the context bundle and answer +the question concisely. Write your full response to the output file specified below. + +## Context bundle + +Read this file fully before answering: /tmp/ask-minimax-ctx-TS.md + +The bundle contains CONTEXT.md and CLAUDE.md files collected from a project directory +tree, deepest-first. Each section is prefixed with "## Context from: " so you +know where each piece of context comes from. + +## Question + +QUESTION + +## Output file + +Write your complete response to: /tmp/ask-minimax-TS-result.md + +Use the Write tool. Overwrite if it already exists. + +## Constraints + +- Read the context bundle fully before answering +- Keep your answer concise — this is a focused question, not an open-ended task +- Write the complete result to the output file +- One-line stdout acknowledgement is fine; content goes in the output file +``` + +### Step 5 — Run the sub-session + +Substitute `TS` with the actual timestamp integer before running: + +```bash +ask-minimax-run \ + --model MiniMax-M2.7 \ + --allowedTools "Read,Write" \ + --dangerously-skip-permissions \ + -p "$(cat /tmp/ask-minimax-TS-prompt.txt)" \ + > /tmp/ask-minimax-TS-stdout.txt 2>&1 +``` + +Show the exit code after it completes. + +### Step 6 — Collect and present results + +1. Read `/tmp/ask-minimax-TS-result.md` using the Read tool +2. If not found, read `/tmp/ask-minimax-TS-stdout.txt` as fallback +3. Present a concise summary — do not dump the full file into the conversation +4. Tell the user the result file path if they want the full output + +### Step 7 — Clean up + +```bash +rm -f /tmp/ask-minimax-ctx-TS.md /tmp/ask-minimax-TS-prompt.txt /tmp/ask-minimax-TS-stdout.txt +``` + +Keep the result file.