goals

SKILL.md

Goals - OKR & Goal Tracking System

A comprehensive goal management system supporting OKR hierarchy (Objectives -> Key Results), progress tracking, habit integration, and automated review cycles.

Triggers

  • "set a goal", "new goal", "create goal", "add objective"
  • "track my progress", "update goal", "goal progress"
  • "OKR", "objective", "key result", "KR"
  • "weekly review", "monthly review", "goal review"
  • "show my goals", "list goals", "goals status"
  • "link habit to goal", "habit goal"

Database Schema

Goals Table

Stores objectives and key results in a hierarchical structure.

-- Goals table - OKR hierarchy support
CREATE TABLE IF NOT EXISTS goals (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    telegram_user_id BIGINT NOT NULL,

    -- Hierarchy: NULL parent = Objective, non-NULL parent = Key Result
    parent_id UUID REFERENCES goals(id) ON DELETE CASCADE,

    -- Core fields
    title TEXT NOT NULL,
    description TEXT,

    -- Type: 'objective' or 'key_result'
    goal_type TEXT NOT NULL DEFAULT 'objective' CHECK (goal_type IN ('objective', 'key_result')),

    -- Measurement
    target_value NUMERIC,           -- Target number (e.g., 100 for "Read 100 books")
    current_value NUMERIC DEFAULT 0, -- Current progress
    unit TEXT,                       -- Unit of measurement (books, miles, %, etc.)

    -- Status
    status TEXT DEFAULT 'active' CHECK (status IN ('active', 'paused', 'completed', 'abandoned')),

    -- Time bounds
    start_date DATE DEFAULT CURRENT_DATE,
    target_date DATE,               -- When the goal should be achieved
    completed_at TIMESTAMPTZ,

    -- Categorization
    category TEXT,                  -- work, health, finance, personal, learning, etc.
    priority INTEGER DEFAULT 2 CHECK (priority BETWEEN 1 AND 5), -- 1=highest, 5=lowest

    -- Streaks and milestones
    current_streak INTEGER DEFAULT 0,
    longest_streak INTEGER DEFAULT 0,
    last_progress_at TIMESTAMPTZ,

    -- Linked habits (array of habit IDs)
    linked_habit_ids UUID[],

    -- Metadata
    tags TEXT[],
    metadata JSONB,

    created_at TIMESTAMPTZ DEFAULT NOW(),
    updated_at TIMESTAMPTZ DEFAULT NOW()
);

-- Indexes for goals
CREATE INDEX IF NOT EXISTS idx_goals_user ON goals(telegram_user_id);
CREATE INDEX IF NOT EXISTS idx_goals_parent ON goals(parent_id);
CREATE INDEX IF NOT EXISTS idx_goals_status ON goals(telegram_user_id, status);
CREATE INDEX IF NOT EXISTS idx_goals_type ON goals(telegram_user_id, goal_type);
CREATE INDEX IF NOT EXISTS idx_goals_category ON goals(telegram_user_id, category);
CREATE INDEX IF NOT EXISTS idx_goals_target_date ON goals(telegram_user_id, target_date) WHERE status = 'active';

Goal Progress Table

Tracks individual progress updates and notes.

-- Goal progress entries
CREATE TABLE IF NOT EXISTS goal_progress (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    goal_id UUID NOT NULL REFERENCES goals(id) ON DELETE CASCADE,
    telegram_user_id BIGINT NOT NULL,

    -- Progress data
    value_change NUMERIC NOT NULL,   -- Delta change (can be negative)
    new_value NUMERIC NOT NULL,      -- Resulting value after change

    -- Context
    note TEXT,                       -- Optional note about the progress
    source TEXT,                     -- 'manual', 'habit', 'automated', 'review'
    linked_habit_completion_id UUID, -- If progress came from habit completion

    -- Metadata
    metadata JSONB,
    created_at TIMESTAMPTZ DEFAULT NOW()
);

-- Indexes for goal_progress
CREATE INDEX IF NOT EXISTS idx_goal_progress_goal ON goal_progress(goal_id);
CREATE INDEX IF NOT EXISTS idx_goal_progress_user ON goal_progress(telegram_user_id);
CREATE INDEX IF NOT EXISTS idx_goal_progress_date ON goal_progress(goal_id, created_at DESC);

Habits Table (if not exists)

For linking habits to goals.

-- Habits table for habit-goal linking
CREATE TABLE IF NOT EXISTS habits (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    telegram_user_id BIGINT NOT NULL,

    name TEXT NOT NULL,
    description TEXT,

    -- Frequency: daily, weekly, etc.
    frequency TEXT DEFAULT 'daily' CHECK (frequency IN ('daily', 'weekly', 'monthly', 'custom')),
    frequency_config JSONB,  -- For custom: { "days": [1,3,5], "times_per_week": 3 }

    -- Tracking
    current_streak INTEGER DEFAULT 0,
    longest_streak INTEGER DEFAULT 0,
    total_completions INTEGER DEFAULT 0,
    last_completed_at TIMESTAMPTZ,

    -- Goal contribution
    goal_contribution_value NUMERIC DEFAULT 1, -- How much each completion adds to linked goals

    -- Status
    status TEXT DEFAULT 'active' CHECK (status IN ('active', 'paused', 'archived')),

    -- Metadata
    tags TEXT[],
    metadata JSONB,

    created_at TIMESTAMPTZ DEFAULT NOW(),
    updated_at TIMESTAMPTZ DEFAULT NOW()
);

-- Habit completions
CREATE TABLE IF NOT EXISTS habit_completions (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    habit_id UUID NOT NULL REFERENCES habits(id) ON DELETE CASCADE,
    telegram_user_id BIGINT NOT NULL,

    completed_at TIMESTAMPTZ DEFAULT NOW(),
    note TEXT,

    -- Auto-populated from health data or manual
    source TEXT DEFAULT 'manual' CHECK (source IN ('manual', 'health_data', 'automated')),

    metadata JSONB
);

CREATE INDEX IF NOT EXISTS idx_habits_user ON habits(telegram_user_id);
CREATE INDEX IF NOT EXISTS idx_habits_status ON habits(telegram_user_id, status);
CREATE INDEX IF NOT EXISTS idx_habit_completions_habit ON habit_completions(habit_id);
CREATE INDEX IF NOT EXISTS idx_habit_completions_date ON habit_completions(habit_id, completed_at DESC);

Supabase Configuration

SUPABASE_URL="https://mlzbjnjkopuzoiobinpz.supabase.co"
SUPABASE_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im1semJqbmprb3B1em9pb2JpbnB6Iiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc2NzMzNzk2NCwiZXhwIjoyMDgyOTEzOTY0fQ.9XZOTu4e6igI52WefbOxAGIif4y4i_JJANg36wFXAL4"

Commands

Create an Objective

curl -X POST "$SUPABASE_URL/rest/v1/goals" \
  -H "apikey: $SUPABASE_KEY" \
  -H "Authorization: Bearer $SUPABASE_KEY" \
  -H "Content-Type: application/json" \
  -H "Prefer: return=representation" \
  -d '{
    "telegram_user_id": 302137836,
    "title": "Get in the best shape of my life",
    "description": "Transform physical fitness through consistent training and nutrition",
    "goal_type": "objective",
    "category": "health",
    "priority": 1,
    "target_date": "2026-06-30"
  }'

Create Key Results under an Objective

# Get the parent objective ID first, then create KRs
curl -X POST "$SUPABASE_URL/rest/v1/goals" \
  -H "apikey: $SUPABASE_KEY" \
  -H "Authorization: Bearer $SUPABASE_KEY" \
  -H "Content-Type: application/json" \
  -H "Prefer: return=representation" \
  -d '{
    "telegram_user_id": 302137836,
    "parent_id": "<objective-uuid>",
    "title": "Run 500 miles",
    "goal_type": "key_result",
    "target_value": 500,
    "current_value": 0,
    "unit": "miles",
    "category": "health",
    "target_date": "2026-06-30"
  }'

Update Progress

# First, update goal_progress
curl -X POST "$SUPABASE_URL/rest/v1/goal_progress" \
  -H "apikey: $SUPABASE_KEY" \
  -H "Authorization: Bearer $SUPABASE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "goal_id": "<goal-uuid>",
    "telegram_user_id": 302137836,
    "value_change": 5.2,
    "new_value": 125.2,
    "note": "Morning run in Central Park",
    "source": "manual"
  }'

# Then update the goal's current_value
curl -X PATCH "$SUPABASE_URL/rest/v1/goals?id=eq.<goal-uuid>" \
  -H "apikey: $SUPABASE_KEY" \
  -H "Authorization: Bearer $SUPABASE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "current_value": 125.2,
    "last_progress_at": "2026-01-17T10:30:00Z"
  }'

Query Active Goals with Progress

# Get all active objectives with their key results
curl -s "$SUPABASE_URL/rest/v1/goals?telegram_user_id=eq.302137836&status=eq.active&goal_type=eq.objective&select=*" \
  -H "apikey: $SUPABASE_KEY"

# Get key results for a specific objective
curl -s "$SUPABASE_URL/rest/v1/goals?parent_id=eq.<objective-uuid>&select=*" \
  -H "apikey: $SUPABASE_KEY"

# Get goals due this month
curl -s "$SUPABASE_URL/rest/v1/goals?telegram_user_id=eq.302137836&status=eq.active&target_date=gte.2026-01-01&target_date=lte.2026-01-31&select=*" \
  -H "apikey: $SUPABASE_KEY"

Link Habit to Goal

# Update goal with linked habit ID
curl -X PATCH "$SUPABASE_URL/rest/v1/goals?id=eq.<goal-uuid>" \
  -H "apikey: $SUPABASE_KEY" \
  -H "Authorization: Bearer $SUPABASE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "linked_habit_ids": ["<habit-uuid-1>", "<habit-uuid-2>"]
  }'

OKR Framework

Objective Best Practices

  • Qualitative: Objectives should be inspirational, not numerical
  • Time-bound: Set clear deadlines (quarterly recommended)
  • Ambitious: Should stretch you but be achievable
  • 3-5 per quarter: Don't overload

Key Result Best Practices

  • Quantitative: Must have measurable targets
  • 2-4 per Objective: Keep focused
  • Binary or scalar: Either done/not-done or 0-100%
  • Lead indicators: Measure activities, not just outcomes

Example OKR Structure

Objective: Get in the best shape of my life
├── KR1: Run 500 miles (0/500)
├── KR2: Strength train 100 sessions (0/100)
├── KR3: Maintain body fat under 15% (current: 22%)
└── KR4: Complete a half marathon (binary: not done)

Progress Calculation

For Key Results with Targets

progress_pct = (current_value / target_value) * 100

For Objectives (Average of KRs)

objective_progress = sum(kr.progress_pct for kr in key_results) / len(key_results)

Weighted Progress (Optional)

# If KRs have different priorities
total_weight = sum(kr.priority_weight for kr in key_results)
objective_progress = sum(kr.progress_pct * kr.priority_weight for kr in key_results) / total_weight

Streak Tracking

Streak Logic

  • Daily goals: Streak increments if progress made today, resets if no progress for 2+ days
  • Weekly goals: Streak increments if target met this week
  • Milestone streaks: Track consecutive weeks/months hitting targets

Update Streak Example

# Check last progress and update streak
last_progress=$(curl -s "$SUPABASE_URL/rest/v1/goals?id=eq.<goal-uuid>&select=last_progress_at,current_streak,longest_streak" -H "apikey: $SUPABASE_KEY")

# If streak continues, increment
curl -X PATCH "$SUPABASE_URL/rest/v1/goals?id=eq.<goal-uuid>" \
  -H "apikey: $SUPABASE_KEY" \
  -H "Authorization: Bearer $SUPABASE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "current_streak": 15,
    "longest_streak": 15
  }'

Habit-Goal Integration

When a habit is completed, automatically update linked goals:

Auto-Progress Flow

  1. User completes habit (or auto-detected from health data)
  2. Check if habit has linked_goal_ids
  3. For each linked goal:
    • Add goal_contribution_value to goal's current_value
    • Insert into goal_progress with source: 'habit'
    • Update streak if applicable

Example Habit-Goal Link

Habit: "Daily 5K Run" (contribution_value: 3.1)
├── Linked to: "Run 500 miles" goal
└── Each completion adds 3.1 miles to goal progress

Review Prompts

Weekly Review Questions

  1. What goals did you make progress on this week?
  2. What blocked your progress?
  3. Are your priorities still correct?
  4. What's the #1 thing to focus on next week?
  5. Any goals to pause or abandon?

Monthly Review Questions

  1. How did each objective progress this month?
  2. Are your OKRs still relevant?
  3. What habits most contributed to goal progress?
  4. What new goals should you add?
  5. Celebrate wins: what milestones did you hit?

Cron Jobs

Weekly Review (Sunday 6pm)

Add to cron-jobs.json:

{
  "id": "weekly-goal-review",
  "name": "Weekly Goal Review",
  "description": "Sunday evening OKR and goal review with progress analysis",
  "enabled": true,
  "schedule": {
    "kind": "cron",
    "value": "0 18 * * 0",
    "tz": "America/New_York"
  },
  "sessionTarget": "isolated",
  "payload": {
    "kind": "agentTurn",
    "message": "WEEKLY GOAL REVIEW:\n\n1) FETCH ACTIVE GOALS:\n   Query goals table: SELECT * FROM goals WHERE telegram_user_id = 302137836 AND status = 'active' ORDER BY goal_type, priority;\n\n2) CALCULATE PROGRESS:\n   For each objective, calculate % complete based on key results.\n   Flag any KRs that are behind pace (current < expected based on target_date).\n\n3) STREAK CHECK:\n   Identify goals with active streaks (7+, 30+, 100+ days).\n   Alert if any streaks are at risk of breaking.\n\n4) HABIT CONTRIBUTION:\n   Query habit_completions for this week.\n   Show which habits contributed most to goal progress.\n\n5) WEEKLY QUESTIONS:\n   - What goals made the most progress?\n   - What's blocking progress on stalled goals?\n   - What should be the #1 focus next week?\n   - Any goals to pause or reprioritize?\n\n6) OUTPUT FORMAT:\n   OBJECTIVES SUMMARY:\n   [Objective 1] - X% complete\n     KR1: X/Y (Z%)\n     KR2: X/Y (Z%)\n   \n   STREAKS: [list active streaks]\n   AT RISK: [list goals behind pace]\n   \n   NEXT WEEK FOCUS: [suggestion]\n\nDeliver thoughtful review.",
    "deliver": true,
    "channel": "telegram",
    "to": "302137836"
  }
}

Monthly Review (1st of month, 10am)

{
  "id": "monthly-goal-review",
  "name": "Monthly Goal Review",
  "description": "First of month comprehensive OKR review and planning",
  "enabled": true,
  "schedule": {
    "kind": "cron",
    "value": "0 10 1 * *",
    "tz": "America/New_York"
  },
  "sessionTarget": "isolated",
  "payload": {
    "kind": "agentTurn",
    "message": "MONTHLY GOAL REVIEW (Comprehensive):\n\n1) MONTH IN REVIEW:\n   Query goal_progress for last 30 days.\n   Calculate total progress per goal.\n   Identify biggest wins and struggles.\n\n2) OKR HEALTH CHECK:\n   For each Objective:\n   - Overall progress %\n   - Pace analysis (on track, behind, ahead)\n   - Key Results breakdown\n   - Blockers identified\n\n3) HABIT IMPACT ANALYSIS:\n   Which habits contributed most to goal progress?\n   Any habits to add/remove/modify?\n   Habit streaks summary.\n\n4) QUARTERLY ALIGNMENT:\n   Are goals still aligned with quarterly objectives?\n   Any goals to close, pause, or add?\n   Priority rebalancing needed?\n\n5) MILESTONE CELEBRATION:\n   What milestones were hit this month?\n   Any streaks to celebrate (30+, 100+ days)?\n\n6) NEXT MONTH PLANNING:\n   Top 3 priorities for the month.\n   Key actions to take.\n   Potential blockers to address.\n\n7) OUTPUT FORMAT:\n   MONTHLY SCOREBOARD:\n   | Goal | Start | End | Progress | Status |\n   \n   TOP WINS:\n   - [win 1]\n   - [win 2]\n   \n   FOCUS AREAS:\n   - [priority 1]\n   - [priority 2]\n   \n   MILESTONES:\n   - [celebration 1]\n\nDeliver comprehensive monthly review.",
    "deliver": true,
    "channel": "telegram",
    "to": "302137836"
  }
}

Daily Habit-Goal Sync (9pm)

{
  "id": "daily-habit-goal-sync",
  "name": "Daily Habit-Goal Sync",
  "description": "Sync habit completions to linked goals and update progress",
  "enabled": true,
  "schedule": {
    "kind": "cron",
    "value": "0 21 * * *",
    "tz": "America/New_York"
  },
  "sessionTarget": "isolated",
  "payload": {
    "kind": "agentTurn",
    "message": "DAILY HABIT-GOAL SYNC (Silent unless notable):\n\n1) CHECK TODAY'S HABIT COMPLETIONS:\n   SELECT * FROM habit_completions WHERE DATE(completed_at) = CURRENT_DATE;\n\n2) FOR EACH COMPLETION:\n   - Check if habit has linked goals\n   - Add contribution_value to goal's current_value\n   - Insert goal_progress record with source='habit'\n   - Update goal's last_progress_at\n\n3) STREAK UPDATES:\n   - Update habit streaks (current_streak, longest_streak)\n   - Update goal streaks based on progress frequency\n\n4) MILESTONE CHECK:\n   Alert if any goal hits:\n   - 25% complete\n   - 50% complete\n   - 75% complete\n   - 100% complete\n   - Streak milestones (7, 30, 100 days)\n\n5) OUTPUT:\n   Only deliver message if:\n   - Milestone achieved\n   - Goal completed\n   - Streak milestone hit\n   Otherwise, execute silently.",
    "deliver": false,
    "channel": "telegram",
    "to": "302137836"
  }
}

Output Formats

Goal Status Display

OBJECTIVE: Get in the best shape of my life
Priority: 1 | Category: Health | Due: Jun 30, 2026
Progress: 42% | Status: Active

KEY RESULTS:
  Run 500 miles ........ 210/500 (42%)  [On Track]
  100 strength sessions . 38/100 (38%)  [Behind]
  Body fat under 15% .... 18% -> 15%    [Behind]
  Half marathon ......... Not Started   [At Risk]

STREAKS: Running: 15 days | Gym: 8 days
HABITS LINKED: Daily Run, Gym Session, Meal Prep

Progress Update Confirmation

PROGRESS UPDATED: Run 500 miles

+5.2 miles (Morning run in Central Park)
Total: 215.2 / 500 miles (43%)
Streak: 16 days

5 weeks to target date - need 7.1 mi/week to hit goal.
Current pace: 8.2 mi/week. On Track!

Weekly Summary

WEEKLY GOAL REVIEW - Week of Jan 13, 2026

OBJECTIVES:
1. Get in best shape - 42% (+5% this week)
2. Build side project - 28% (+3% this week)
3. Read 24 books - 17% (no change)

TOP PROGRESS:
  Running goal: +32 miles this week
  Gym sessions: 4/4 completed

NEEDS ATTENTION:
  Reading: No progress - add 30min daily?
  Side project: Blocked on API integration

STREAKS AT RISK:
  Meditation: Last done 2 days ago

NEXT WEEK FOCUS:
  Unblock API integration to continue project.

Examples

User: "Set a goal to read 24 books this year"

  1. Create objective: "Read 24 books in 2026"
  2. Set target_value: 24, unit: "books", target_date: 2026-12-31
  3. Suggest linking to a "Daily reading" habit

User: "I just finished a 5 mile run"

  1. Find active running-related goal
  2. Add 5 to current_value
  3. Insert goal_progress record
  4. Update streak
  5. Confirm: "Added 5 miles to 'Run 500 miles'. Now at 215/500 (43%). Streak: 16 days!"

User: "Show me my goals"

  1. Query all active goals grouped by objective
  2. Calculate progress percentages
  3. Show streak status
  4. Highlight any goals behind pace

User: "Link my daily run habit to my fitness goal"

  1. Find the habit ID
  2. Find the goal ID
  3. Add habit to goal's linked_habit_ids array
  4. Confirm the link

User: "Weekly review"

  1. Trigger the weekly review prompt
  2. Calculate all progress
  3. Ask reflection questions
  4. Suggest focus for next week

Notes

  • Goals support both binary (done/not done) and scalar (0-100) tracking
  • Objectives can have 0 key results (standalone goals) or many
  • Habit completions auto-contribute to linked goals via nightly sync
  • All progress is logged for historical analysis
  • Streaks reset after 2 days of no progress (configurable)
  • Use priority 1-5 to weight importance (1 = most important)
Weekly Installs
1
First Seen
Feb 6, 2026
Installed on
replit1
openclaw1
opencode1
cursor1
codex1
claude-code1