| name | learn |
| description | Extract organizational patterns and conventions from repos + history |
| when_to_use | Use when extracting organizational intelligence — patterns, conventions, and team dynamics mined from git history and the databayt repos into memory; feeds the conventions/patterns/drift surfaces. Distinct from /analyze which generates a repo's Claude config. Triggers on: learn, what are our conventions, extract patterns from history. |
| argument-hint | [repo] [--since DATE] |
Learn — Organizational Intelligence
Extract patterns, conventions, team dynamics, and company knowledge from git history and code.
Usage
/learn — Full org scan (all databayt repos)
/learn hogwarts — Deep dive into a single repo
/learn team — People patterns and work dynamics
/learn conventions — Code patterns only (candidate rules)
/learn health — Velocity and quality metrics
Argument: $ARGUMENTS
Instructions
Parse arguments:
- No args → full org scan
- Repo name → single repo deep dive (hogwarts, souq, mkan, shifa, kun, codebase)
team → people patterns
conventions → code conventions only
health → velocity metrics only
Mode: Full Org Scan (no args)
-
List all repos:
gh repo list databayt --limit 50 --json name,pushedAt,isArchived --jq '.[] | select(.isArchived == false)'
-
For each active repo, extract:
- Last 200 commits:
gh api repos/databayt/<repo>/commits?per_page=100
- Contributors:
gh api repos/databayt/<repo>/contributors
- Languages:
gh api repos/databayt/<repo>/languages
- Open issues/PRs count
-
Cross-reference patterns:
- Which repos share the same stack?
- Which repos have drifted in conventions?
- Where is activity concentrated?
-
Store insights in memory: ~/.claude/memory/learn_org_<date>.md
-
Report key findings to the user.
Mode: Single Repo (/learn <repo>)
-
Navigate to repo (local path or clone):
cd /Users/abdout/<repo>
-
Git history analysis:
git log --oneline -50
git log --format='%s' -100 | head -20
git log --format=format: --name-only -200 | sort | uniq -c | sort -rn | head -20
git log --format='%an' -200 | sort | uniq -c | sort -rn
git log --oneline -200 | grep -c "feat:" ; git log --oneline -200 | grep -c "fix:"
-
Structure analysis:
find . -type d -maxdepth 3 -not -path '*/node_modules/*' -not -path '*/.git/*' -not -path '*/.next/*'
cat package.json | jq '{name, dependencies, devDependencies}'
ls -la prisma/schema.prisma 2>/dev/null
ls .claude/ 2>/dev/null
-
Convention extraction — read 5-10 representative files:
- A
page.tsx — how pages are structured
- An
actions.ts — how server actions are written
- A component — how components are organized
- A form — how forms handle validation
- The middleware — how auth works
-
Store in memory: ~/.claude/memory/learn_<repo>.md
-
Report: conventions found, drift from org patterns, health metrics.
Mode: Team (/learn team)
-
Scan all repos for author patterns:
for repo in hogwarts souq mkan shifa kun codebase; do
echo "=== $repo ==="
cd /Users/abdout/$repo 2>/dev/null && git log --since="3 months ago" --format='%an|%aI' | head -50
cd /Users/abdout
done
-
Build team map:
- Who works on which repos
- Peak activity hours
- Commit frequency trends
- Expertise areas (most-touched directories)
-
Store in memory: ~/.claude/memory/learn_team.md
Mode: Conventions (/learn conventions)
-
Sample files across repos — focus on patterns, not people:
- File naming conventions
- Import patterns (barrel vs direct)
- Auth check patterns
- Validation patterns
- Component structure
- i18n handling
-
Output as candidate rules (not memory — rules are actionable):
Observed: 94% of server actions follow auth→validate→execute→revalidate
→ Candidate rule: rules/server-actions.md
Observed: 100% use conventional commits
→ Already documented in CLAUDE.md ✓
Observed: 3 repos use barrel imports, 1 doesn't
→ Candidate rule: rules/no-barrel-imports.md (with migration note)
-
Ask user: "Found N candidate rules. Generate rule files? (Y/n)"
Mode: Health (/learn health)
-
Numbers only — across all repos:
| Repo | Commits/30d | Fix:Feat | Hotspot File | Last Push |
|-----------|-------------|----------|-------------------------|------------|
| hogwarts | 89 | 0.3 | src/app/admission/... | 2 hours |
| kun | 34 | 0.1 | .claude/agents/_index | 1 day |
| souq | 12 | 0.5 | src/components/cart/... | 1 week |
-
Trends: compare this month to last month.
-
Flags: repos with no activity > 2 weeks, high fix ratio, large commits.
Memory Storage
All learn outputs go to ~/.claude/memory/ with type project:
---
name: learn_<scope>
description: Intelligence extracted from <scope> — <date>
type: project
---
<findings>
Update existing memory files rather than creating duplicates. Check MEMORY.md first.
What Learn Never Does
- Modifies code (read-only)
- Creates PRs (that's analyze's job)
- Makes decisions (that's captain's job)
- Generates config (that's analyze's job)
Rule: Learn reads everything, remembers what matters, and makes every other agent smarter. Knowledge is the engine's fuel.