Capture learning from completed work interactively
Captures lessons learned from completed work and stores them in your ACE playbook.
/plugin marketplace add ce-dot-net/ce-claude-marketplace/plugin install ace@ce-dot-net-marketplaceManually capture patterns and lessons learned from your recent work using Claude Code's native UI.
When the user runs /ace:learn, follow these steps:
Use the AskUserQuestion tool to collect learning details:
{
questions: [
{
question: "What task did you just complete?",
header: "Task",
multiSelect: false,
options: [
{
label: "Implemented new feature",
description: "Built new functionality or component"
},
{
label: "Fixed bug or issue",
description: "Debugged and resolved a problem"
},
{
label: "Refactored code",
description: "Improved code structure or performance"
},
{
label: "Integrated API/library",
description: "Connected external service or tool"
}
]
}
]
}
Then ask for task description in "Other" field or follow-up question.
{
questions: [
{
question: "Was the task successful?",
header: "Outcome",
multiSelect: false,
options: [
{
label: "Success",
description: "Task completed successfully"
},
{
label: "Partial success",
description: "Completed but with issues or compromises"
},
{
label: "Failed",
description: "Task failed or was abandoned"
}
]
}
]
}
{
questions: [
{
question: "What did you learn? (key insights, gotchas, solutions)",
header: "Lessons",
multiSelect: false,
options: [
{
label: "Enter lessons in 'Other' field",
description: "Describe insights, gotchas, best practices discovered"
}
]
}
]
}
User will provide detailed lessons in the "Other" text input.
If in a git repository, capture git context for AI-Trail correlation (Issue #6):
#!/usr/bin/env bash
set -euo pipefail
# Check if in a git repository
GIT_CONTEXT=""
if git rev-parse --git-dir >/dev/null 2>&1; then
echo "š Gathering git context..."
# Get current branch
BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "")
# Get recent commit info
COMMIT_HASH=$(git rev-parse --short HEAD 2>/dev/null || echo "")
COMMIT_MSG=$(git log -1 --format=%s 2>/dev/null || echo "")
# Get changed files (staged + unstaged) - returns List[str] per Issue #7
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD 2>/dev/null | head -20 | jq -R -s -c 'split("\n") | map(select(length > 0))' || echo "[]")
# Build git context JSON
GIT_CONTEXT=$(jq -n \
--arg branch "$BRANCH" \
--arg commit "$COMMIT_HASH" \
--arg message "$COMMIT_MSG" \
--argjson files "$CHANGED_FILES" \
'{branch: $branch, commit_hash: $commit, commit_message: $message, files_changed: $files}')
echo " Branch: $BRANCH"
echo " Commit: $COMMIT_HASH"
echo ""
fi
if ! command -v ace-cli >/dev/null 2>&1; then
echo "ā ace-cli not found - Install: npm install -g @ace-sdk/cli"
exit 1
fi
# Read context from .claude/settings.json
ORG_ID=$(jq -r '.orgId // .env.ACE_ORG_ID // empty' .claude/settings.json 2>/dev/null || echo "")
PROJECT_ID=$(jq -r '.projectId // .env.ACE_PROJECT_ID // empty' .claude/settings.json 2>/dev/null || echo "")
# Also try env wrapper format
if [ -z "$ORG_ID" ] || [ -z "$PROJECT_ID" ]; then
ORG_ID=$(jq -r '.env.ACE_ORG_ID // empty' .claude/settings.json 2>/dev/null || echo "")
PROJECT_ID=$(jq -r '.env.ACE_PROJECT_ID // empty' .claude/settings.json 2>/dev/null || echo "")
fi
if [ -z "$PROJECT_ID" ]; then
echo "ā Run /ace:configure first"
exit 1
fi
echo "š [ACE Learning] Capturing patterns from your work..."
echo ""
# Build ace-cli command based on success status
if [ "$SUCCESS_STATUS" = "Success" ]; then
SUCCESS_FLAG="--success"
elif [ "$SUCCESS_STATUS" = "Failed" ]; then
SUCCESS_FLAG="--failure"
else
# Partial success - treat as success with note in output
SUCCESS_FLAG="--success"
LESSONS_LEARNED="Partial success: $LESSONS_LEARNED"
fi
# Build JSON payload for --stdin (includes optional git context)
LEARN_PAYLOAD=$(jq -n \
--arg task "$TASK_DESCRIPTION" \
--arg output "$LESSONS_LEARNED" \
--argjson success "$([ "$SUCCESS_FLAG" = "--success" ] && echo true || echo false)" \
--argjson git "${GIT_CONTEXT:-null}" \
'{task: $task, output: $output, success: $success, git: $git}')
# Call ace-cli learn with --stdin for richer payload
if [ -n "$ORG_ID" ]; then
echo "$LEARN_PAYLOAD" | ace-cli --json --org "$ORG_ID" --project "$PROJECT_ID" \
learn --stdin
else
# Single-org mode (no --org flag)
echo "$LEARN_PAYLOAD" | ace-cli --json --project "$PROJECT_ID" \
learn --stdin
fi
if [ $? -eq 0 ]; then
echo "ā
Patterns captured successfully!"
echo " Run /ace:status to see updated playbook"
else
echo "ā Failed to capture patterns"
exit 1
fi
Key Points:
--success flag--failure flag--success with note in outputorgId) and env wrapper (env.ACE_ORG_ID)Error Handling:
ā Use /ace:learn after:
ā Skip for:
User: /ace:learn
Claude: [Shows AskUserQuestion UI]
Question 1: What task did you just complete?
User selects: "Fixed bug or issue"
User types in Other: "Debugged intermittent test failures in async database operations"
Claude: [Shows AskUserQuestion UI]
Question 2: Was the task successful?
User selects: "Success"
Claude: [Shows AskUserQuestion UI]
Question 3: What did you learn?
User types in Other: "Root cause was missing await on database.close() causing connection pool exhaustion. Intermittent failures in async code often indicate missing await statements. Always check async cleanup functions."
Claude runs:
ace-cli --json --org "org_xxx" --project "prj_xxx" learn \
--task "Debugged intermittent test failures in async database operations" \
--success \
--output "Root cause was missing await on database.close() causing connection pool exhaustion. Intermittent failures in async code often indicate missing await statements. Always check async cleanup functions."
ā
Patterns captured successfully!
Run /ace:status to see updated playbook
The learning event sent to ACE includes:
branch: Current git branch namecommit_hash: Current commit SHAcommit_message: Latest commit messagefiles_changed: List of modified file paths (Issue #7)The ACE server's Reflector analyzes this and the Curator updates the playbook with new patterns.
/ace:status - View playbook statistics/ace:patterns - Browse learned patterns/ace:search <query> - Find relevant patterns/ace:bootstrap - Initialize from codebase