
Apex Learn
- 4 installs
- 2 repo stars
- Updated March 14, 2026
- othmanadi/apex
Analyze task friction and append reusable rules and preferences to AGENTS.md so the agent improves across sessions.
About
Runs a self-improvement retrospective after a task, extracting friction points and persisting reusable rules to AGENTS.md. A developer uses it after a task involved struggle or correction so the agent avoids repeating mistakes.
- Two-strike rule: a repeated correction triggers a permanent rule
- Classifies learnings and appends them to AGENTS.md
Apex Learn by the numbers
- 4 all-time installs (skills.sh)
- +1 installs in the week ending Aug 4, 2026 (Skillselion tracking)
- Ranked #2,331 of 3,282 Productivity & Planning skills by installs in the Skillselion catalog
- Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/othmanadi/apex --skill apex-learnAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 4 |
|---|---|
| repo stars | ★ 2 |
| Last updated | March 14, 2026 |
| Repository | othmanadi/apex ↗ |
What it does
Analyze task friction and append reusable rules and preferences to AGENTS.md so the agent improves across sessions.
Files
APEX Learn
Analyze what happened during a task, extract reusable knowledge, and persist it to AGENTS.md so the entire agent team improves over time.
When to Use
Run this skill in any of these situations:
- After completing a Tier 1, 2, or 3 task
- When the human corrected you on the same issue twice (two-strike rule)
- When you discovered a non-obvious pattern or convention
- When a task took significantly longer than expected
- When the human explicitly asks to update the rules
The Two-Strike Rule
This is the core mechanism. If you are corrected on the same type of issue twice:
1. First correction — Fix the issue, note it mentally 2. Second correction — Fix the issue AND run apex-learn to add a permanent rule
This prevents the same mistake from recurring across sessions.
Workflow
1. Identify friction points 2. Classify the learning 3. Draft the rule 4. Append to AGENTS.md 5. Verify the update
Step 1: Identify Friction Points
Ask yourself these questions about the completed task:
## Friction Analysis
1. Where did I get stuck or make mistakes?
2. What did the human correct me on?
3. What took longer than expected and why?
4. What assumptions did I make that were wrong?
5. What patterns did I discover that aren't documented?Step 2: Classify the Learning
Each learning falls into one of these categories:
| Category | Example | Where it Goes in AGENTS.md |
|---|---|---|
| Code style | "Always use named exports" | ## Code Style section |
| Architecture | "Services never call controllers" | ## Architecture Rules section |
| Workflow | "Always run tests before committing" | ## Workflow section |
| Boundaries | "Never modify the auth module" | ## Boundaries section |
| Preferences | "Prefer descriptive over short names" | ## Preferences section |
| Tool usage | "Use pnpm, not npm" | ## Tools section |
Step 3: Draft the Rule
Write the rule in imperative form. Be specific and actionable:
Good rules:
- Always use `pnpm` instead of `npm` for package management
- Never modify files in `src/auth/` without explicit approval
- When creating API endpoints, always include rate limiting middlewareBad rules:
- Be careful with packages (too vague)
- Try to write good code (not actionable)
- Remember the auth thing (not specific)Step 4: Append to AGENTS.md
Run the learning script to safely append the new rule:
Linux/Mac:
bash "${CLAUDE_SKILL_DIR}/scripts/append-learning.sh" "<category>" "<rule-text>"Windows:
powershell -File "${CLAUDE_SKILL_DIR}/scripts/append-learning.ps1" "<category>" "<rule-text>"If AGENTS.md does not exist, create it using the template in references/agents-template.md.
Step 5: Verify the Update
Read AGENTS.md after the update. Confirm:
- The new rule is in the correct section
- It does not duplicate an existing rule
- It does not contradict an existing rule
- The file is still well-formatted
If a contradiction is found, present both rules to the human and ask which takes priority.
Output
An updated AGENTS.md file with the new rule appended to the correct section, committed with message docs: apex-learn — add rule for {category}.
Example diff:
## Tools
+- Always use `pnpm` instead of `npm` for package management
+- Run `pnpm install --frozen-lockfile` in CI environments
## Learnings Log
+### 2026-03-14: Package Manager
+- Agent used npm twice before this rule was added
+- Root cause: default behavior, no explicit instructionExample commit:
docs: apex-learn — add rule for tools
Added package manager preference after two-strike correction.
Agent was defaulting to npm instead of pnpm.AGENTS.md — Project Intelligence
This file is the project's living memory. It is read by AI agents before every task.
Rules are added automatically via apex-learn when patterns are discovered.Do not delete rules without understanding why they were added.
Identity
- Project: {PROJECT_NAME}
- Stack: {TECH_STACK}
- Package Manager: {PACKAGE_MANAGER}
The Two-Strike Rule
If you are corrected on the same issue twice:
1. First correction — Fix the issue, note it mentally 2. Second correction — Fix it AND add a permanent rule to this file
This prevents the same mistake from recurring across sessions. When adding a rule, place it in the appropriate section below.
Self-Improvement
After any task where you struggled or were corrected, ask yourself:
1. What did I learn? 2. Should anything be added to this file?
If the human corrects you twice on the same thing, immediately add a rule using apex-learn.
Tone
- Never claim you are "absolutely right" about something
- Do not be a yes-man — push back respectfully when you disagree or see problems
- Admit uncertainty when you're not confident
- If you made a mistake, acknowledge it directly without excessive apology
Code Style
Architecture Rules
Workflow
- Always create a feature branch before making changes
- Run the full validation chain (lint, types, tests, build) before committing
- Run the formatter before committing
- Always create a new commit rather than amending an existing one (preserves history for review)
- Open draft PRs for review — never push directly to main
- Write descriptive commit messages:
type(scope): description
Boundaries
- Never modify files outside the assigned task scope
- Never commit secrets, API keys, or credentials
- Never remove failing tests — fix them or flag for review
- Never push to main or production branches directly
Preferences
Tools
Learnings Log
<!-- New learnings are appended here by apex-learn -->
# APEX Learn — Append Learning to AGENTS.md (Windows)
# Safely appends a new rule to the correct section of AGENTS.md.
# Usage: powershell -File append-learning.ps1 "<category>" "<rule-text>" [agents-file]
param(
[Parameter(Mandatory=$true, Position=0)]
[string]$Category,
[Parameter(Mandatory=$true, Position=1)]
[string]$Rule,
[Parameter(Position=2)]
[string]$AgentsFile = "AGENTS.md"
)
$ErrorActionPreference = "Stop"
# Map category to section header
$Sections = @{
"code-style" = "## Code Style"
"architecture" = "## Architecture Rules"
"workflow" = "## Workflow"
"boundaries" = "## Boundaries"
"preferences" = "## Preferences"
"tools" = "## Tools"
}
$Section = $Sections[$Category]
if (-not $Section) {
Write-Error "Unknown category '$Category'. Valid: code-style, architecture, workflow, boundaries, preferences, tools"
exit 1
}
# Create AGENTS.md from template if it doesn't exist
if (-not (Test-Path $AgentsFile)) {
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$Template = Join-Path (Split-Path -Parent $ScriptDir) "references" "agents-template.md"
if (Test-Path $Template) {
Copy-Item $Template $AgentsFile
Write-Host "Created $AgentsFile from template."
} else {
Write-Error "$AgentsFile does not exist and template not found."
exit 1
}
}
# Check for duplicate
$content = Get-Content $AgentsFile -Raw
if ($content -match [regex]::Escape($Rule)) {
Write-Host "SKIP: This rule already exists in $AgentsFile."
exit 0
}
# Find the section and append the rule
$lines = Get-Content $AgentsFile
$sectionIndex = -1
for ($i = 0; $i -lt $lines.Count; $i++) {
if ($lines[$i] -eq $Section) {
$sectionIndex = $i
break
}
}
if ($sectionIndex -ge 0) {
# Insert after the section header
$newLines = @()
$newLines += $lines[0..$sectionIndex]
$newLines += "- $Rule"
if ($sectionIndex -lt ($lines.Count - 1)) {
$newLines += $lines[($sectionIndex + 1)..($lines.Count - 1)]
}
$newLines | Set-Content $AgentsFile -Encoding UTF8
Write-Host "ADDED: Rule appended to '$Section' in $AgentsFile"
} else {
# Section doesn't exist, append at end
Add-Content $AgentsFile "`n$Section`n- $Rule" -Encoding UTF8
Write-Host "ADDED: Created '$Section' section with rule in $AgentsFile"
}
Write-Host ""
Write-Host "Rule: $Rule"
Write-Host "Category: $Category"
Write-Host "File: $AgentsFile"
#!/usr/bin/env bash
# APEX Learn — Append Learning to AGENTS.md (Linux/Mac)
# Safely appends a new rule to the correct section of AGENTS.md.
# Usage: bash append-learning.sh "<category>" "<rule-text>" [agents-file]
set -euo pipefail
CATEGORY="${1:-}"
RULE="${2:-}"
AGENTS_FILE="${3:-AGENTS.md}"
if [ -z "$CATEGORY" ] || [ -z "$RULE" ]; then
echo "Usage: bash append-learning.sh \"<category>\" \"<rule-text>\" [agents-file]"
echo ""
echo "Categories: code-style, architecture, workflow, boundaries, preferences, tools"
exit 1
fi
# Map category to section header
declare -A SECTIONS=(
["code-style"]="## Code Style"
["architecture"]="## Architecture Rules"
["workflow"]="## Workflow"
["boundaries"]="## Boundaries"
["preferences"]="## Preferences"
["tools"]="## Tools"
)
SECTION="${SECTIONS[$CATEGORY]:-}"
if [ -z "$SECTION" ]; then
echo "ERROR: Unknown category '$CATEGORY'."
echo "Valid categories: code-style, architecture, workflow, boundaries, preferences, tools"
exit 1
fi
# Create AGENTS.md from template if it doesn't exist
if [ ! -f "$AGENTS_FILE" ]; then
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
TEMPLATE="$SCRIPT_DIR/../references/agents-template.md"
if [ -f "$TEMPLATE" ]; then
cp "$TEMPLATE" "$AGENTS_FILE"
echo "Created $AGENTS_FILE from template."
else
echo "ERROR: $AGENTS_FILE does not exist and template not found."
exit 1
fi
fi
# Check for duplicate
if grep -qF "$RULE" "$AGENTS_FILE" 2>/dev/null; then
echo "SKIP: This rule already exists in $AGENTS_FILE."
exit 0
fi
# Find the section and append the rule after it
if grep -q "^$SECTION" "$AGENTS_FILE"; then
# Find line number of the section, then find the next blank line or section to insert before
SECTION_LINE=$(grep -n "^$SECTION" "$AGENTS_FILE" | head -1 | cut -d: -f1)
# Insert the rule after the section header
sed -i "${SECTION_LINE}a\\- ${RULE}" "$AGENTS_FILE"
echo "ADDED: Rule appended to '$SECTION' in $AGENTS_FILE"
else
# Section doesn't exist, append it at the end
echo "" >> "$AGENTS_FILE"
echo "$SECTION" >> "$AGENTS_FILE"
echo "- $RULE" >> "$AGENTS_FILE"
echo "ADDED: Created '$SECTION' section with rule in $AGENTS_FILE"
fi
echo ""
echo "Rule: $RULE"
echo "Category: $CATEGORY"
echo "File: $AGENTS_FILE"