A comprehensive AI-powered financial coaching system built with HeyLua that guides small business owners through 5 levels of financial maturity—from basic compliance to strategic mastery.
- Overview
- The 5-Level System
- Quick Start
- Agent Architecture
- Directory Structure
- Skills & Tools
- How It Works
- Deployment
- Key Features
The Mesh Financial Coach is an intelligent agent that:
- ✅ Assesses users' current financial practices (one-time evaluation)
- ✅ Assigns them to 1 of 5 maturity levels
- ✅ Guides them through 3 modules per level
- ✅ Tracks progress and automatically levels them up
- ✅ Sends personalized reminders based on their journey
- ✅ Grounds all advice in educational principles (never gives specific investment advice)
The agent embodies the Cautious Mentor philosophy:
NEVER:
- ❌ Give specific investment advice ("Buy this stock")
- ❌ Make purchasing decisions ("You should buy this equipment")
- ❌ Guarantee financial outcomes ("Do this and you'll make $X")
ALWAYS:
- ✅ Educate on principles (separation, tracking, forecasting)
- ✅ Ask guiding questions ("What's your target gross margin?")
- ✅ Empower users to make their own informed decisions
Goal: Basic compliance and habit formation
Modules:
- The Separation Rule - Open separate business bank account
- Digital Capture Setup - Implement digital expense tracking
- 5-Receipt Challenge - Capture 5 receipts in one week
Key Concepts: Personal vs. business accounts, digital capture, basic categories (Revenue, Costs, Transfers)
Goal: Consistent data capture and monthly review cycles
Modules:
- Monthly Filing Cycle - Complete first full monthly reconciliation
- Revenue Stream Definition - Identify and name 3 primary revenue sources
- Fixed Cost Budgeting - Calculate monthly survival number
Key Concepts: Monthly reconciliation, revenue stream visibility, fixed vs. variable costs
Goal: Forecasting and forward planning
Modules:
- P&L Mastery - Understand Net P&L vs. bank balance
- Proactive Tax Savings - Set up 30% tax savings system
- Forecast Initiation - Create first 3-month cash flow forecast
Key Concepts: P&L vs. bank balance, quarterly tax savings, rolling cash flow forecasts
Goal: Strategic growth and investment
Modules:
- Reinvestment Strategy - Define profit allocation (Tax/Owner/Reinvest)
- Delegation & Automation - Identify first task to delegate
- COGS Calculation - Separate Cost of Goods Sold from Operating Expenses
Key Concepts: Strategic reinvestment, time value, gross margin, COGS vs. OpEx
Goal: Optimization and long-term resilience
Modules:
- Building Cash Reserves - Establish 6-month operating reserve
- Quarterly Review Cycle - Complete strategic quarterly review
- Mentorship Simulation - Demonstrate Cautious Mentor approach
Key Concepts: Cash reserves, quarterly reviews, teaching others
node >= 20.x
npm >= 9.x# Install dependencies
npm install
# Build TypeScript
npm run buildLoad full RAG educational content to the Data Primitive:
npm run load-dataNote: The agent works without this step (using embedded metadata), but full content provides richer guidance.
# Test tools individually
lua test
# Chat with agent in sandbox mode
lua chat# Compile for deployment
lua compile
# Push all components and deploy
lua push all --force --auto-deploy┌─────────────────────────────────────────────────┐
│ Mesh Financial Coach Agent │
│ (Cautious Mentor Persona) │
└─────────────────────────────────────────────────┘
│
┌───────────────┴───────────────┐
↓ ↓
┌───────────────────┐ ┌──────────────────┐
│ Financial Coach │ │ Dynamic Jobs │
│ Skill │ │ (Per-User) │
└───────────────────┘ └──────────────────┘
│
├── MaturityAssessmentTool
├── CompleteModuleTool
├── CheckLevelProgressTool
└── GetLevelContentTool
- User starts → Agent calls
check_level_progress - New user? → Run
run_maturity_assessment(one-time) - Progress tracking → Use
complete_modulewhen user demonstrates competency - Content retrieval → Use
get_level_contentto ground responses - Proactive pings → Jobs created dynamically after assessment/completion
mesh-financial-coach/
│
├── src/
│ ├── index.ts # Main agent configuration
│ │
│ ├── data/ # RAG educational content
│ │ ├── rag_level1.md # Level 1 full content
│ │ ├── rag_level2.md # Level 2 full content
│ │ ├── rag_level3.md # Level 3 full content
│ │ ├── rag_level4.md # Level 4 full content
│ │ ├── rag_level5.md # Level 5 full content
│ │ └── levelContentMap.ts # Metadata (compiled with agent)
│ │
│ ├── skills/
│ │ ├── financial-coach.skill.ts # Main coaching skill
│ │ └── tools/
│ │ └── FinancialCoachTools.ts # All 4 coaching tools
│ │
│ └── utils/
│ └── loadRAGContent.ts # Data loading utility (setup only)
│
├── scripts/
│ └── loadData.ts # CLI script to load RAG content
│
├── lua.skill.yaml # Skill registry and configuration
├── package.json # Dependencies and scripts
└── README.md # This file
| File | Purpose | When Used |
|---|---|---|
src/index.ts |
Agent definition with persona | Always (core) |
src/skills/financial-coach.skill.ts |
Groups coaching tools | Always (core) |
src/skills/tools/FinancialCoachTools.ts |
All 4 coaching tools | Always (core) |
src/data/levelContentMap.ts |
Embedded metadata (fallback) | Always (compiled in) |
src/data/rag_level*.md |
Full educational content | Optional (for Data Primitive) |
src/utils/loadRAGContent.ts |
Loads markdown to Data Primitive | Setup only |
scripts/loadData.ts |
CLI wrapper for data loading | Setup only |
Name: financial-coach-skill
Version: 1.0.0
Purpose: Provides all tools needed to assess, track, and coach users through financial maturity levels
Tool Name: run_maturity_assessment
Purpose: Evaluates user's current financial practices through 5 questions and assigns them to a starting level (1-5).
Input Schema:
{
q1_score: number (1-5), // Separate business account?
q2_score: number (1-5), // Capture expenses digitally?
q3_score: number (1-5), // Review finances regularly?
q4_score: number (1-5), // Forecast/plan for taxes?
q5_score: number (1-5) // Systems for growth?
}Scoring Logic:
- 5-8 points → Level 1 (Financial Starter)
- 9-12 points → Level 2 (Tracker)
- 13-16 points → Level 3 (Planner)
- 17-20 points → Level 4 (Scaler)
- 21-25 points → Level 5 (Master)
What It Does:
- Calculates total score
- Assigns appropriate level
- Initializes
habit_tracking(all modules marked incomplete) - Saves to User Primitive
- Creates first proactive ping job (7 days out)
Output:
{
success: true,
total_score: 8,
assigned_level: 1,
level_name: "The Financial Starter",
level_description: "Focus on basic compliance...",
message: "Assessment complete! You've been assigned...",
next_steps: "Start with Module 1...",
ping_scheduled: "Habit check scheduled for Nov 14, 2025"
}Important: This should only run ONCE per user. Always check check_level_progress first.
Tool Name: complete_module
Purpose: Marks a module as complete after user demonstrates competency, checks for level-up, and creates next reminder job.
Input Schema:
{
level: number (1-5), // Which level
module: number (1-3), // Which module
verification_method: "quiz" | "action_confirmation" | "user_input",
verification_details: string // What user provided
}Verification Methods:
- quiz: User answered a knowledge question correctly
- action_confirmation: User confirmed completing an action
- user_input: User provided required information
What It Does:
- Validates module is for current level or below
- Marks module as complete in
habit_tracking - Checks if all 3 modules in level are complete
- If complete → Level up! Initialize next level's modules
- Creates dynamic job for next milestone (7 days out)
- Updates User Primitive
Output (Level Up):
{
success: true,
module_completed: "Level 1, Module 3",
verification_method: "action_confirmation",
all_modules_complete: true,
leveled_up: true,
new_level: 2,
new_level_name: "The Tracker",
message: "🎉 Congratulations! You've completed all modules..."
}Output (Module Complete, Not Level Up):
{
success: true,
module_completed: "Level 2, Module 1",
verification_method: "quiz",
all_modules_complete: false,
leveled_up: false,
new_level: 2,
message: "Module 1 of Level 2 marked complete! Continue with..."
}Dynamic Job Creation:
- After module completion → Job for next module
- After level-up → Job for new level's Module 1
- All jobs scheduled for 7 days in the future
Tool Name: check_level_progress
Purpose: Retrieves user's current level, progress, and module completion status. Call this FIRST at the start of every conversation.
Input Schema:
{
include_details: boolean (optional, default: true) // Include all module details?
}What It Does:
- Fetches user's state from User Primitive
- Checks if they've been assessed
- Calculates progress percentage
- Returns detailed module status
Output (Assessed User):
{
success: true,
assessed: true,
current_level: 2,
level_name: "The Tracker",
current_level_progress: {
completed_modules: 1,
total_modules: 3,
progress_percentage: 33,
modules: [
{ module: 1, completed: true },
{ module: 2, completed: false },
{ module: 3, completed: false }
]
},
all_modules: {
level_1: [...],
level_2: [...]
},
assessment_date: "2025-11-07T10:00:00Z",
last_module_completed: "2025-11-08T14:30:00Z",
ready_for_level_up: false,
message: "User is at Level 2: The Tracker. Progress: 1/3 modules..."
}Output (Not Assessed):
{
success: true,
assessed: false,
message: "User has not yet completed the maturity assessment...",
recommendation: "Use run_maturity_assessment tool..."
}Critical: This is the FIRST tool to call in every conversation to avoid re-assessing users.
Tool Name: get_level_content
Purpose: Retrieves educational content for a specific level to ground AI responses in the curriculum.
Input Schema:
{
level: number (1-5) // Which level's content to retrieve
}How It Works:
- Try Data Primitive first (if
npm run load-datawas executed) - Fallback to embedded metadata (always available, compiled with agent)
Output (Full Content - Data Primitive):
{
success: true,
level: 2,
levelName: "The Tracker",
description: "Consistent tracking, monthly reviews...",
content: "# Level 2: The Tracker\n\n[Full markdown content]...",
contentLength: 12543,
source: "data_primitive",
message: "Retrieved full educational content for Level 2..."
}Output (Metadata Fallback):
{
success: true,
level: 2,
levelName: "The Tracker",
description: "Consistent tracking, monthly reviews...",
modules: [
{ module: 1, name: "Monthly Filing Cycle", focus: "..." },
{ module: 2, name: "Revenue Stream Definition", focus: "..." },
{ module: 3, name: "Fixed Cost Budgeting", focus: "..." }
],
source: "embedded_metadata",
content_summary: "Level 2: The Tracker\n\nModules:\n...",
message: "Retrieved metadata for Level 2...",
note: "Using embedded metadata. For full content, run npm run load-data"
}Use Case: Agent calls this to understand what to teach at each level and ground responses in curriculum.
Day 0: Sarah Starts
Sarah: "Hi, I need help with my business finances."
Agent: [Calls check_level_progress] → Not assessed
Agent: "Let me understand your current situation with 5 quick questions..."
Sarah: [Answers 5 questions]
Agent: [Calls run_maturity_assessment with scores]
Result: Sarah assigned Level 1 (Financial Starter)
Action: Job created for Day 7
Day 3: Sarah Completes Module 1
Sarah: "I opened my business bank account!"
Agent: [Calls complete_module(level: 1, module: 1, method: "action_confirmation")]
Result: Module 1 marked complete
Action: Job created for Day 10 (Module 2 reminder)
Day 7: First Job Fires
Job: Checks Sarah's progress
→ Module 1 already complete!
→ Sends: "✅ Well done! You've already completed this module..."
(Smart: Job detected completion and sent encouragement instead of redundant reminder)
Day 10: Sarah Completes Module 2
Sarah: "I set up my expense tracker in QuickBooks."
Agent: [Calls complete_module(level: 1, module: 2, method: "action_confirmation")]
Result: Module 2 marked complete
Action: Job created for Day 17 (Module 3 reminder)
Day 15: Sarah Completes Module 3 (Final in Level 1)
Sarah: "I captured 7 receipts this week!"
Agent: [Calls complete_module(level: 1, module: 3, method: "action_confirmation")]
Result: All Level 1 modules complete → LEVEL UP!
New Level: Level 2 (The Tracker)
Action: Job created for Day 22 (Level 2, Module 1 reminder)
Day 22: Level 2 Job Fires
Job: Sends "🎯 The Tracker - Time to Start! You leveled up a week ago. Ready to dive into Module 1?"
- One-Time Assessment: Assessment never runs twice (checked via
check_level_progress) - Dynamic Jobs: Each action creates the next reminder (7 days out)
- Smart Job Execution: Jobs check actual progress before sending messages
- Automatic Level-Up: Completing all 3 modules triggers level advancement
- Personalized Timing: Jobs based on THEIR actions, not global schedule
- Graceful Fallback: Agent works even if Data Primitive content not loaded
When a job fires, it doesn't blindly send a reminder. Instead, it:
- Checks user's current state (level, module completion)
- Detects if module is already complete or if user has leveled up
- Adapts the message based on actual progress:
- Module incomplete → Send original reminder
- Module complete → Send encouragement
- User leveled up → Congratulate progress
- All modules complete → Suggest level-up conversation
This prevents redundant reminders and keeps messages relevant!
- Code compiles:
npm run build - (Optional) Load RAG content:
npm run load-data - Test locally:
lua chat(sandbox) - Verify tools work: Test assessment and module completion
# 1. Compile TypeScript
npm run build
# 2. Compile for Lua platform
lua compile
# 3. Push all components
lua push all --force --auto-deploy# Check production status
lua production
# Test in production
lua chat # Select Production mode- One-time evaluation (never repeats)
- 5 questions covering all financial areas
- Automatic level assignment (1-5)
- Saved permanently to user profile
- 15 total modules (5 levels × 3 modules each)
- Three verification types: quiz, action, input
- Automatic level-up when all modules complete
- Real-time progress calculation
- Jobs created per user, per action
- 7-day spacing between action and reminder
- Context-aware messages (knows which module)
- No global cron jobs (scales infinitely)
- Full RAG content available (optional)
- Embedded metadata (always works)
- Fallback mechanism (never fails)
- Cautious Mentor philosophy (educate, don't prescribe)
- TypeScript for type safety
- Zod schemas for input validation
- Error handling throughout
- No file system access at runtime
- Create
src/data/rag_level6.mdwith content - Update
src/data/levelContentMap.ts:6: { level: 6, levelName: "The Expert", description: "...", modules: [...] }
- Update tool schemas to accept level 6
- Run
npm run load-data(if using Data Primitive)
Edit the module messages in CompleteModuleTool or add new verification logic as needed.
Change the 7-day interval in MaturityAssessmentTool and CompleteModuleTool:
nextPingDate.setDate(nextPingDate.getDate() + 7); // Change this number- ✅ Personalized timing (respects each user's pace)
- ✅ Context-aware (knows their level/module)
- ✅ Scalable (works for 1 or 10,000 users)
- ✅ No wasted resources (only runs when needed)
- ✅ Prevents re-assessing returning users
- ✅ Maintains continuity (pick up where they left off)
- ✅ Better user experience (no redundant questions)
- ✅ Always works (no dependency on Data Primitive)
- ✅ Graceful degradation (full content if available, metadata otherwise)
- ✅ Fast (compiled with agent code)
- ✅ Security (agents shouldn't access local files)
- ✅ Cloud-native (works in any deployment environment)
- ✅ Performance (Data Primitive optimized for reads)
Solution: The agent now uses embedded metadata as fallback. This error shouldn't occur, but if it does:
npm run load-data # Load full content to Data PrimitiveProblem: Agent not checking progress first
Solution: Ensure agent persona includes "Always check check_level_progress FIRST"
Problem: Job creation might have failed
Check: Look for errors in CompleteModuleTool or MaturityAssessmentTool output
Problem: Verification details missing or user not at that level
Solution: Ensure module being completed is for user's current level
- Lua Docs: https://docs.heylua.ai
- CLI Reference: https://docs.heylua.ai/mcp
# Development
npm run build # Compile TypeScript
npm run load-data # Load RAG content to Data Primitive
# Lua CLI
lua test # Test tools locally
lua chat # Interactive chat (sandbox or production)
lua compile # Compile for deployment
lua push all # Push all components
lua deploy # Deploy to production
lua production # Check production statusISC
The Mesh Financial Coach is a complete, production-ready AI coaching system that:
- Assesses users once and tracks their journey through 5 levels
- Provides 15 modules of progressive financial education
- Sends personalized reminders based on each user's timeline
- Grounds all advice in educational principles
- Works reliably with built-in fallbacks
Ready to deploy and start coaching! 🚀