codeskill — AI Project Intelligence System
You manage the
directory in projects — rules, behaviours, memory, snapshots, sessions, incidents, and learning loops.
Command Routing
Parse
to determine which command to execute:
If ARGS starts with "init"
Scaffold a new
directory in the current project.
- Check if already exists. If yes, ask user: " already exists. Overwrite? (This won't delete logs/memory)"
- Detect project type by reading go.mod, package.json, pyproject.toml, etc.
- Get the user's GitHub username: and
- Create the directory structure:
bash
mkdir -p .ai/{behaviours,skills/{backend,frontend,infra},workflows,guides}
mkdir -p .ai/{snippets,prompts,memory/{feedback,decisions},templates}
mkdir -p .ai/{logs/{sessions,activity,incidents},plans/features,tasks,snapshots,handoffs}
- Create Tier 0 files:
- — project-specific rules (start with generated code table, code style, commits)
- — empty with header and instructions
- — project taste template with @username placeholders
- Create Tier 1 files:
- — if project type detected, scan main dirs and describe structure
- — extract from dependency files (go.mod, package.json, etc.)
- — empty with header
- Create domain skill files based on project type:
- Go project →
.ai/skills/backend/RULES.md
, ,
- Node project →
.ai/skills/frontend/RULES.md
, ,
- Create INDEX.md files for: , , , , , , ,
- Create from (master checklist)
- Create directory and from
- Create behaviour files: , , , , with
- Copy templates from this skill's directory into
- Create :
logs/
CONTINUATION.md
memory/decisions/
tasks/
- Run the command to generate CLAUDE.md
- Report: " initialized. Edit RULES.md and taste.md, then run ."
If ARGS starts with "sync"
Regenerate CLAUDE.md from
Tier 0 files.
- Read these source files (skip any that don't exist):
- (if global dir exists)
- (if global dir exists)
.ai/behaviours/default.md
(or current active behaviour)
- Read
.ai/logs/sessions/INDEX.md
— get the last session entry for "Where We Left Off"
- Read the CLAUDE.md template from this skill's
- Assemble CLAUDE.md:
- Header with generation notice
- "Where We Left Off" section from last session
- Critical Rules (concatenate global + project RULES.md)
- Active Hotfixes
- Taste (global, then project overrides)
- Active Behaviour
- Memory Protocol instructions
- Exploration Protocol instructions
- Before Starting Work checklist
- Auto-Behaviour Hints
- Workflow Index (scan for files)
- After Session instructions
- Reference links
- Write to project root
- Report: "CLAUDE.md regenerated. Tier 0: ~[X] lines."
If ARGS starts with "behaviour"
Switch or list behaviour profiles.
If ARGS is "behaviour list":
- Glob (exclude README.md)
- For each, read the frontmatter and
- Print table: name, description, active?
If ARGS is "behaviour [name]":
- Check exists
- If not, list available behaviours and ask user to pick
- Read the behaviour file
- Run to regenerate CLAUDE.md with new active behaviour
- Report: "Switched to mode."
If ARGS starts with "learn"
Mid-session learning — save AND apply immediately in the current session.
This is the user saying "learn this NOW" — not waiting for session end.
- Parse what to learn from ARGS after "learn"
- Classify the learning type:
- Contains "always"/"never" → rule candidate
- Contains "I prefer"/"I hate"/"I like" → taste candidate
- Contains code/pattern → snippet/pattern candidate
- Contains "remember"/"don't forget" → factual memory
- Otherwise → correction/feedback
- Classify scope (project/global_candidate) using standard logic
- Check for duplicates in memory/feedback/ and RULES.md
- If similar exists → update it instead of creating new
- Save to
.ai/memory/feedback/<slug>.md
with trigger: "user explicit (learn this)"
- APPLY IMMEDIATELY — add to your working context for the rest of this session:
- Treat it as highest-priority rule for current conversation
- Don't wait for session end
- Check promotion: Is this the 3rd+ time this correction was saved?
- If yes → propose adding to RULES.md or taste.md right now
- If no → report occurrence count
- If this looks like a taste update (style/naming/preference):
- Ask: "Should I update taste.md with this? (It will apply to all future sessions)"
- Report: "Learned and applying now: <summary>. Occurrence #<N>."
Undo: If user says "undo the last thing I told you to learn" or "I changed my mind about X":
- Find the most recent feedback/ entry from this session (or matching X)
- Delete it
- Remove from in-session working context
- Report: "Removed: <summary>. No longer applying."
If ARGS starts with "session start"
Load context and report status.
- Get user info: ,
- Check for in project root:
- If exists: read it, report "Resuming from: [task]", delete the file
- Read — report active hotfixes count
- Read
.ai/logs/sessions/INDEX.md
— get last session date
- Session diff: run
git log --oneline --since="<last_session_date>"
to see what changed
- Check snapshot staleness: for each snapshot in , run
git diff --name-only <hash> HEAD -- <globs>
- Report:
Session started for @<username>
Last session: <date> — <goal>
Since then: <N> commits, <files changed>
Hotfixes active: <N>
Snapshots: <N> fresh, <N> stale
If ARGS starts with "session end"
Write session summary and activity log.
- Get user info from git config
- Ask user (or infer from conversation): "What was the goal of this session?"
- Scan the conversation for:
- Files changed (from tool calls)
- Decisions made
- Corrections received
- Mistakes / incidents
- Generate timestamp:
- Write session log to
.ai/logs/sessions/<timestamp>.md
using template:
markdown
# Session: <timestamp>
**User**: <name> (<email>)
**GitHub**: @<username>
**Goal**: <goal>
**Outcome**: <completed|partial|failed>
**Behaviour**: <active behaviour>
**Files Changed**: <count>
## Actions
- <bullet list of what was done>
## Decisions Made
- <decisions, linked to memory/decisions/ if saved>
## Corrections Received
- <corrections, linked to memory/feedback/ if saved>
## Mistakes
- <any mistakes or incidents>
- Write activity log to
.ai/logs/activity/<timestamp>.md
using compact format:
markdown
# Activity: <timestamp>
**User**: <name> (<email>)
**GitHub**: @<username>
**Behaviour**: <active>
**Prompt Count**: <N>
---
## #1 — <time>
"<user prompt>"
→ Loaded: <workflow> | Files: <files> | Correction: <yes/no>
## #2 — <time>
...
- Update
.ai/logs/sessions/INDEX.md
— append one-line entry
- Update
.ai/logs/activity/INDEX.md
— append one-line entry
- Update "Where We Left Off" and run to regenerate CLAUDE.md
- Check promotion thresholds:
- Any feedback item with 3+ occurrences? → suggest RULES.md update
- Any hotfix 30+ days without recurrence? → suggest graduation/archive
- Report: "Session logged. <N> corrections saved, <N> decisions logged."
If ARGS starts with "continue"
Load emergency resume file.
- Check for in project root
- If not found: "No continuation file found. Start a fresh session with ."
- If found: read and display it, then delete it
- Report: "Loaded resume point. Continuation file deleted."
If ARGS starts with "feedback"
Save a user correction to memory.
- Get user info from git config
- Parse the correction from ARGS (after "feedback"), or ask user to describe it
- Classify:
- Does it reference project-specific files/paths? →
- Is it about general coding/AI behaviour? →
- Check for duplicates: grep for similar content
- If similar exists: update the existing entry instead of creating new
- Generate filename from correction summary (slugified)
- Write to
.ai/memory/feedback/<slug>.md
:
markdown
---
date: <today>
type: correction
user: "@<username>"
scope: <project|global_candidate>
trigger: "<what AI did wrong>"
---
<correction content>
- Update
- Apply immediately in current session (add to working context)
- If scope is : "This looks global (no project-specific refs). Consider adding to your global repo."
- Report: "Saved correction to memory/feedback/<slug>.md. Applying for this session."
If ARGS starts with "decide"
Log an AI decision to memory.
- Get user info from git config
- Parse decision title and context from ARGS
- Ask user if not provided:
- What was decided?
- What alternatives were considered?
- Why this choice?
- Classify scope (same logic as feedback)
- Write to
.ai/memory/decisions/<slug>.md
:
markdown
---
date: <today>
type: decision
user: "@<username>"
scope: <project|global_candidate>
context: "<what prompted this decision>"
---
# <Decision Title>
**Decision**: <what was decided>
**Alternatives**: <what else was considered>
**Why**: <reasoning>
**Trade-off**: <what we gave up>
**Outcome**: pending review
- Update
- Report: "Decision logged to memory/decisions/<slug>.md"
If ARGS starts with "incident"
Create an incident report.
- Get user info from git config
- Parse description from ARGS, or ask user to describe what went wrong
- Check
.ai/logs/incidents/INDEX.md
for similar past incidents (same category)
- Count recurrences
- Generate timestamp filename
- Write to
.ai/logs/incidents/<date>-<slug>.md
:
markdown
# Incident: <short description>
**Date**: <today>
**User**: @<username>
**Severity**: <low|medium|high|critical>
**Category**: <generated-code|db-access|graphql|config|deployment|testing|other>
**Rule Violated**: <ref or "none — new rule needed">
**Recurrence**: <1st|2nd|Nth>
## What Happened
<description>
## Root Cause
<why the AI made this mistake>
## Detection Signal
<how to catch this next time>
## Prevention
- [ ] Added to HOTFIXES.md (if recurrence >= 2)
- [ ] Updated relevant workflow/rule
- [ ] Saved correction to memory/feedback/
- Update
.ai/logs/incidents/INDEX.md
- If recurrence >= 2: auto-add to and run
- Report: "Incident logged. Recurrence: <N>." + hotfix promotion if applicable
If ARGS starts with "hotfix"
If ARGS is "hotfix add [description]":
- Parse description
- Assign next HF-NNN number (read HOTFIXES.md for highest)
- Append to
- Run to update CLAUDE.md
- Report: "Added HF-<NNN> to HOTFIXES.md."
If ARGS is "hotfix review":
- Read
- For each hotfix, check
.ai/logs/incidents/INDEX.md
for last recurrence date
- Flag hotfixes with no recurrence in 30+ days
- For each stale hotfix, ask user: "Graduate to RULES.md, or archive?"
- Apply changes, run
If ARGS starts with "snapshot"
If ARGS is "snapshot list":
- Read
- For each entry, run:
git diff --name-only <git_hash> HEAD -- <watched_globs>
- Print table: topic | last updated | status (fresh/stale) | files changed
If ARGS is "snapshot check [topic]":
- Read frontmatter
- Run:
git diff --name-only <git_hash> HEAD -- <watched_globs>
- Report: "fresh" or "stale (N files changed: ...)"
If ARGS is "snapshot refresh [topic]":
- Read frontmatter for
- Spawn an Explore agent scoped to those file globs
- Write exploration findings to with fresh git_hash from
- Update
- Report: "Snapshot <topic> refreshed."
If ARGS is "snapshot refresh --all":
- Run snapshot list logic, find all stale snapshots
- For each stale one, run snapshot refresh
If ARGS is "snapshot create [topic]":
- Ask user: "What files/dirs should this snapshot cover?" (get globs)
- Spawn Explore agent for that area
- Write with frontmatter: topic, description, git_hash, files_watched
- Update
- Report: "Snapshot <topic> created."
If ARGS starts with "snippet"
If ARGS is "snippet [name]":
-
Search
for matching name/tags
-
If found: display it
-
If not found: ask user for code, tags, usage context
-
markdown
# Snippet: <Name>
**Tags**: <tag1, tag2>
**Used in**: <context>
## Code
```<lang>
<code>
When to Use
<description>
```
-
If ARGS starts with "prompt"
If ARGS is "prompt [name]":
- Search for matching name
- If found: display it
- If not found: ask user for template text, tags, workflow reference
- Write to :
markdown
# Prompt: <Name>
**Tags**: <tag1, tag2>
**Workflow**: <workflow reference or "none">
**Behaviour**: <recommended behaviour>
## Template
<prompt template text with [PLACEHOLDERS]>
## Variants
<optional variant prompts>
- Update
If ARGS starts with "plan"
Manage feature plans. Plans live in
.
If ARGS is "plan [title]" — Create a new feature plan:
- Parse title from ARGS, generate slug (kebab-case)
- Ensure exists — if not, create from
- Ensure directory exists
- Ask user for: goal, non-goals, requirements with priorities
- Write to
.ai/plans/features/<slug>-plan.md
using
- Update — add entry to Active Plans table
- Report: "Plan created at plans/features/<slug>-plan.md"
If ARGS is "plan list" — Show all plans:
- Read
- Display active and completed tables
If ARGS is "plan archive [slug]" — Archive a completed plan:
- Move
.ai/plans/features/<slug>-plan.md
to .ai/memory/plans/<slug>-plan.md
- Move entry from Active to Completed in PLAN.md
- Report: "Plan archived to memory/plans/"
If ARGS starts with "task"
Manage the task system. Tasks live as individual files in
with a master checklist at
.
If ARGS is "task add [description]" — Create a new task:
- Parse description and infer priority (or ask user)
- Determine next ID: scan and for highest , next = N+1
- Generate slug from description (kebab-case)
- Write
.ai/tasks/task{id}_{slug}.md
:
markdown
---
id: {id}
title: '<title>'
status: pending
priority: <high|medium|low>
feature: '<feature or plan name if relevant>'
dependencies: []
created_at: "<timestamp>"
---
## Description
<what needs to be done>
## Details
- <specific requirements or steps>
## Test Strategy
<how to verify this is done>
- Update — append entry:
- [ ] **ID {id}: {Title}** (Priority: {priority})
- Report: "Task {id} created: {title}"
If ARGS is "task list" — Show all tasks:
- Read and display
If ARGS is "task start [id]" — Start working on a task:
- Read task file, check dependencies are all completed
- If dependencies not met → report which are blocking
- Complexity check — before starting, assess if the task needs expansion:
- Involves changes across 3+ unrelated files/modules?
- Has 5+ acceptance criteria or detail items?
- Would take more than ~2-3 hours of focused work?
- Has high uncertainty or multiple distinct outcomes?
If YES to 2+ of these → recommend expansion:
- Propose sub-tasks with titles, descriptions, dependencies
- Ask user: "This task looks complex. Expand into sub-tasks?"
- If user agrees → create sub-tasks as , , etc.
- Update parent task's Details section with sub-task list
- If user declines → proceed normally
- Update task YAML: ,
- Update entry: →
- Report: "Started task {id}: {title}"
If ARGS is "task done [id]" — Mark task completed:
- If task has → ask user: "Run tests or mark complete?"
- Update task YAML: ,
completed_at: <timestamp>
- Update entry: →
- Report: "Completed task {id}: {title}"
If ARGS is "task fail [id] [reason]" — Mark task failed:
- Update task YAML: , ,
completed_at: <timestamp>
- Update entry →
- Report: "Failed task {id}: {reason}"
If ARGS is "task next" — Start the next available task:
- Read , find first (pending) entry
- Check its dependencies
- If met → start it (same as )
- If not met → find next pending with met dependencies
If ARGS is "task archive" — Archive completed/failed tasks:
- Scan for files with or
- For each:
- Read full content (title, description, dependencies)
- Move file to
- Append to :
- Archived **ID {id}: {Title}** (Status: {status}) on {timestamp}
- Remove entry from
- Report: "Archived {N} tasks to memory/tasks/"
If ARGS is "task show [id]" — Show task details:
- Find in or
- Display full content
TASKS.md icons:
- pending
- in-progress
- completed
- failed
If ARGS starts with "handoff"
Generate a handoff document for downstream repos/teams.
If ARGS is "handoff [plan-slug]" — Generate handoff from a plan:
- Read
.ai/plans/features/<slug>-plan.md
- If plan has no "Handoff Context" section or it's empty → ask user:
- What downstream repo needs this?
- What was built? (endpoints, schemas, events)
- What's the interface contract? (response shapes, payloads)
- Decisions that affect downstream?
- How to sync? (SDK regen command, config update)
- Fill the "Handoff Context" section in the plan
- Also generate a standalone handoff file at :
markdown
# Handoff: <Plan Title>
**From**: <this repo>
**To**: <downstream repo>
**Date**: <today>
**Plan**: plans/features/<slug>-plan.md
## What Was Built
<endpoints, schemas, APIs, events>
## Interface Contract
<response shapes, payloads, types>
## Decisions Affecting Downstream
<key choices that downstream needs to know about>
## How to Sync
<commands to run, config to update, deploy steps>
## Tasks for Downstream
- [ ] <suggested task 1>
- [ ] <suggested task 2>
- Report: "Handoff generated. Share with downstream repo."
If ARGS is "handoff list" — Show all handoffs:
- List files in
If ARGS starts with "memory search"
Search feedback and decisions.
- Parse query from ARGS after "memory search"
- Grep and for the query
- Display matching entries with file paths
If ARGS starts with "status"
Show current system state.
- Read active behaviour (from CLAUDE.md or behaviours/)
- Count active hotfixes in HOTFIXES.md
- Count recent incidents (last 30 days) from logs/incidents/INDEX.md
- Check snapshot staleness (summary: N fresh, N stale)
- Count feedback entries and decisions
- Read last session from logs/sessions/INDEX.md
- Print summary:
codeskill status
─────────────────
Behaviour: default
Hotfixes: 3 active
Incidents: 2 (last 30 days)
Snapshots: 8 fresh, 2 stale
Memory: 12 feedback, 5 decisions
Last session: 2026-04-17 by @khanakia — "Add avatar upload"
If ARGS starts with "health"
Score system health 1-10.
- Freshness (30%): Check dates on snapshots, last session, HOTFIXES
- Relevance (30%): Verify file paths referenced in memory/feedback still exist
- Completeness (20%): Check core files exist (RULES.md, taste.md, HOTFIXES.md, at least 1 snapshot)
- Actionability (20%): Check "Where We Left Off" in CLAUDE.md is present and specific
- Compute weighted score
- Print per-dimension scores and total
- If < 5: suggest
If ARGS starts with "compress"
Run auto-compression on logs, memory, hotfixes.
- Check line counts of:
- (cap: 75 lines)
- (cap: 150 lines)
- individual files (cap: 150 lines each)
- (cap: 150 lines)
- For each file over cap:
- HOTFIXES: suggest graduating oldest to RULES.md or archiving
- Session INDEX: archive entries older than 30 days
- Activity logs: truncate oldest prompts, keep corrections
- Memory INDEX: merge similar entries
- Report: "Compressed N files. Removed N stale entries."
If ARGS starts with "recover"
Recovery mode — rebuild from git + code.
- Warn user: "Recovery mode will re-explore the codebase and verify all stored data. Continue?"
- Scan project: read go.mod/package.json, README, directory structure
- Read git history:
- Re-explore and regenerate all stale snapshots
- Verify file paths in memory/feedback/ and memory/decisions/ — flag broken refs
- Rebuild ARCHITECTURE.md and STACK.md if missing
- Run to regenerate CLAUDE.md
- Report: "Recovery complete. Health score: <N>/10"
If ARGS starts with "save-state"
Write emergency CONTINUATION.md.
- Scan conversation for: current task, files being edited, what's done, what's in progress
- Write to project root (max 50 lines):
markdown
# Continue: <task>
Resume from: `<file:line>` — <what was being done>
## State
- [x] <completed items>
- [ ] <in progress items>
- [ ] <remaining items>
## Immediate Next Action
<exact next step>
- Report: "State saved to CONTINUATION.md. Next session will auto-load it."
If ARGS starts with "export"
If ARGS is "export cursor":
- Read , ,
- Generate files from the content
- Report: "Generated .cursor/rules/ from .ai/"
If ARGS is "export copilot":
- Read , ,
- Generate
.github/copilot-instructions.md
- Report: "Generated copilot-instructions.md from .ai/"
If ARGS is empty or "help"
Show available commands:
codeskill — AI Project Intelligence System
Setup:
init Scaffold .ai/ directory
sync Regenerate CLAUDE.md from .ai/ files
status Show current state
Behaviours:
behaviour <name> Switch mode (default, careful, review, debug, scaffold)
behaviour list List available behaviours
Session:
session start Load context, check staleness, report status
session end Write session log + activity log
continue Load CONTINUATION.md resume point
save-state Write emergency CONTINUATION.md
Learning:
learn <lesson> Learn NOW — save + apply immediately in current session
feedback <correction> Save user correction to memory
decide <title> Log a decision to memory
incident <description> Create incident report
hotfix add <desc> Add to active hotfixes
hotfix review Review stale hotfixes for graduation
Assets:
snippet <name> Find or create code snippet
prompt <name> Find or create prompt template
Planning:
plan <title> Create feature plan in plans/features/
plan list Show all active and completed plans
plan archive <slug> Move completed plan to memory/plans/
handoff <plan-slug> Generate handoff doc for downstream repo/team
handoff list Show all handoffs
Tasks:
task add <description> Create task file + add to TASKS.md
task list Show master checklist (TASKS.md)
task start <id> Start task (check dependencies first)
task done <id> Mark task completed
task fail <id> <reason> Mark task failed with reason
task next Start next available pending task
task archive Archive completed/failed to memory/tasks/
task show <id> Show full task details
Memory:
memory search <query> Search feedback and decisions
Snapshots:
snapshot list Show all + staleness
snapshot check <topic> Check specific snapshot
snapshot refresh <topic> Re-explore and update
snapshot refresh --all Refresh all stale
snapshot create <topic> Create new snapshot
Maintenance:
health Score system health 1-10
compress Auto-compress logs, memory, hotfixes
recover Rebuild from git + code
Export:
export cursor Generate .cursor/rules/
export copilot Generate copilot-instructions.md
Important Rules for This Skill
- Never modify CLAUDE.md directly — always run to regenerate it
- Every feedback/decision entry needs: date, user (@username), scope (project/global_candidate/global)
- Auto-save corrections: When you detect user corrections during normal work (not just when this skill is invoked), save them to memory/feedback/
- Check before exploring: Always check snapshots before spawning Explore agents
- Compact encoding: All .ai/ files use tables > prose, file:line refs, one-line summaries
- Never store secrets in any .ai/ file