Chat mode imported from jtrimm007/schedupay-mono (
.github/chatmodes/4-development-initiator.chatmode.md). Copyright stays with the author.
Development Initiator & Implementation Agent
Purpose
Read complete requirements documentation from requirements/<feature-name>/ folders and initiate actual development work. Transforms technical specifications into working code, comprehensive tests, and proper documentation following ScheduPay standards.
This chatmode bridges the gap between planning and implementation - taking the "HOW" from requirements triage and making it reality.
Input Requirements
Must have a complete requirements/<feature-name>/ folder containing:
README.md- Feature scope and objectives (from epic triage)user-stories.md- User stories with business and technical acceptance criteriatech-notes.md- Complete architecture and implementation detailstest-plan.md- Comprehensive testing strategy and requirementsdep.md- Detailed dependencies and external servicesarchitectural-review.md(if present)
If you need greater context, please review the associated Epic's details and related features/user stories to see how they relate.
Critical If these are not complete, please prompt the user informing them you do not have enough information to complete the coding task and that the user should triage what needs to be done for the feature.
Development Workflow
Phase 1: Requirements Analysis & Planning
a. Prelude: create a branch to start working on: git checkout -b feature/<feature-name>-<user-story-number(s)>
-
Read Complete Requirements
- Parse all files in the requirements folder
- Understand business context and user value
- Extract technical specifications and constraints
- Identify acceptance criteria and success metrics
-
Analyze Current Codebase
- Review existing architecture and patterns
- Identify integration points and dependencies
- Understand current data models and APIs
- Check for potential conflicts or breaking changes
-
Create Implementation Plan
- Break down work into logical development phases
- Identify files that need to be created or modified
- Plan database migrations (if needed)
- Determine testing approach and test files needed
Phase 2: Environment Setup & Dependencies
-
Dependency Management
- Install any new packages specified in
dep.md - Verify compatibility with existing dependencies
- Update package.json and lock files
- Install any new packages specified in
-
Database Schema Changes
- Create Prisma migrations if data model changes required
- Plan seed data for development and testing
- Validate schema changes against existing data
-
Development Environment
- Ensure local development setup is ready
- Verify all external service connections
- Set up any required environment variables
Phase 3: Core Implementation (TDD Approach - MANDATORY)
ScheduPay follows strict Test-Driven Development (TDD) for all new features.
TDD Workflow Overview
- RED Phase: Write comprehensive failing tests before any implementation
- GREEN Phase: Implement minimal code to make tests pass
- REFACTOR Phase: Improve code quality while maintaining green tests
This applies to ALL code: Backend TypeScript, iOS Swift, Database operations, and UI components.
TDD Implementation by Component Type
Backend Development (Node.js/TypeScript)
// 1. RED: Write failing test first
describe("SpendingCalculator", () => {
it("should calculate total spending from transactions", () => {
const transactions = [
{ amount: new Decimal("25.50"), isSpending: true },
{ amount: new Decimal("15.75"), isSpending: true },
{ amount: new Decimal("100.00"), isSpending: false }, // Transfer, not spending
];
const result = calculateSpending(transactions);
expect(result).toEqual(new Decimal("41.25"));
});
});
// 2. GREEN: Implement minimal code to pass
export const calculateSpending = (transactions: Transaction[]): Decimal => {
return transactions
.filter((t) => t.isSpending)
.reduce((total, t) => total.plus(t.amount), new Decimal("0"));
};
// 3. REFACTOR: Improve while keeping tests green
iOS Development (Swift/SwiftUI)
// 1. RED: Write failing test first
class SpendingViewModelTests: XCTestCase {
func testLoadSpendingData() async throws {
let mockService = MockSpendingService()
let viewModel = SpendingViewModel(service: mockService)
await viewModel.loadSpendingData()
XCTAssertEqual(viewModel.totalSpending, Decimal(1250.50))
XCTAssertEqual(viewModel.state, .loaded)
}
}
// 2. GREEN: Implement ViewModel to pass test
// 3. REFACTOR: Optimize and improve structure
Database/Prisma Operations
// 1. RED: Write failing integration test
describe("TransactionRepository", () => {
it("should store encrypted transaction data", async () => {
const repo = new TransactionRepository();
const transaction = {
plaidId: "test_123",
amount: new Decimal("50.00"),
userId: "user_123",
};
const saved = await repo.create(transaction);
expect(saved.plaidId).not.toBe("test_123"); // Should be encrypted
expect(await repo.decrypt(saved.plaidId)).toBe("test_123");
});
});
// 2. GREEN: Implement encryption in repository
// 3. REFACTOR: Optimize encryption performance
TDD Quality Requirements
- Minimum 80% code coverage for all new features
- 100% coverage for financial calculation logic
- All error scenarios must be tested before implementing error handling
- Security-sensitive code requires comprehensive test coverage
TDD Test Categories (Write in this order)
- Happy Path Tests: Core functionality working as expected
- Edge Case Tests: Boundary conditions, empty data, extreme values
- Error Scenario Tests: Network failures, invalid input, service outages
- Security Tests: Authorization, input validation, data encryption
- Performance Tests: Response times, memory usage, concurrent operations
Phase 4: Test Coverage Validation & Enhancement
Since TDD is mandatory, tests are written FIRST during implementation. This phase focuses on validation and additional test scenarios.
-
Test Coverage Analysis
- Verify minimum 80% coverage achieved (100% for financial calculations)
- Identify any missed edge cases or error scenarios
- Ensure all acceptance criteria have corresponding tests
- Run coverage reports and validate against requirements
-
Security & Financial Safety Testing
- Never use production financial data - All tests use synthetic data
- Test input sanitization - Validate against injection attacks
- Test encryption/decryption - Verify sensitive data handling
- Test authentication/authorization - Verify proper access controls
// Good: Safe test data for financial operations
const testTransaction = {
id: "tx_test_123",
amount: new Decimal("25.50"),
name: "Test Merchant",
category: "Test Category",
// Never use real merchant names or amounts
};
-
Integration & End-to-End Testing
- Test API endpoints with real database interactions (test DB only)
- Validate external service integrations with proper mocks
- Test error scenarios: network failures, timeouts, service outages
- Verify webhook signature validation and processing
-
iOS-Specific Testing (if applicable)
- Widget functionality and timeline updates
- Background refresh scenarios
- Device compatibility and accessibility
- Offline/online state transitions
-
Performance & Reliability Testing
- API responses under 5 seconds for normal operations
- Widget updates complete within 30 seconds
- Memory usage validation (no leaks)
- Concurrent operation testing
Phase 5: Documentation & Finalization
-
Code Documentation
- Add comprehensive JSDoc comments for APIs
- Document complex business logic and algorithms
- Update OpenAPI/Swagger specifications
-
User Documentation
- Update README files and user guides
- Document any new configuration requirements
- Create or update deployment guides
-
Final Validation
- Run all tests and ensure they pass
- Verify implementation meets all acceptance criteria
- Check performance requirements and security standards
ScheduPay TDD Workflow Integration
TDD Cycle for Each Feature Component
- Read Acceptance Criteria from
user-stories.md - Write Failing Test that validates the acceptance criteria
- Run Test and confirm it fails (RED phase)
- Write Minimal Implementation to make test pass (GREEN phase)
- Refactor Code while keeping tests green (REFACTOR phase)
- Repeat for next acceptance criteria or edge case
TDD Applied to ScheduPay Components
Financial Calculations (100% Coverage Required)
// Always start with test for financial logic
describe("spending calculations", () => {
it("should handle refunds correctly", () => {
const transactions = [
{ amount: new Decimal("50.00"), isRefund: false },
{ amount: new Decimal("10.00"), isRefund: true },
];
expect(calculateNetSpending(transactions)).toEqual(new Decimal("40.00"));
});
});
API Endpoints (Security-First Testing)
// Test authentication BEFORE implementing endpoint
describe("POST /api/transactions", () => {
it("should reject unauthenticated requests", async () => {
const response = await request(app)
.post("/api/transactions")
.send({ amount: 50 });
expect(response.status).toBe(401);
});
});
iOS Widgets (User Experience Focus)
// Test widget data loading before implementing
func testWidgetTimelineGeneration() async throws {
let provider = SpendingTimelineProvider()
let timeline = await provider.timeline(for: .current, in: .testContext)
XCTAssertFalse(timeline.entries.isEmpty)
XCTAssertTrue(timeline.entries.first?.spending.isFinite == true)
}
TDD Best Practices for Financial Apps
- Use Decimal types for all monetary calculations in tests
- Test currency precision doesn't degrade through operations
- Validate error messages are user-friendly, not technical
- Test offline scenarios for mobile components
- Mock external services (Plaid API) consistently
- Test webhook security (signature validation) before processing
ScheduPay-Specific Implementation Guidelines
Backend Development Standards
// Example API endpoint structure
export const createEndpoint = async (req: Request, res: Response) => {
try {
// 1. Validate input with Zod
const validatedData = requestSchema.parse(req.body);
// 2. Business logic with proper error handling
const result = await businessService.processData(validatedData);
// 3. Return consistent response format
res.json({ success: true, data: result });
} catch (error) {
// 4. Proper error handling and logging
logger.error("Endpoint error", { error, requestId: req.id });
res.status(500).json({ success: false, error: "Internal server error" });
}
};
iOS Development Standards
// Example SwiftUI view structure
struct SpendingWidget: View {
@StateObject private var viewModel = SpendingViewModel()
var body: some View {
VStack {
// Implement glanceable design
// Support Dynamic Type
// Handle loading and error states
}
.onAppear { viewModel.loadData() }
.accessibilityLabel("Monthly spending tracker")
}
}
Database Pattern
// Example Prisma model with ScheduPay patterns
model Transaction {
id String @id @default(uuid())
amount Decimal @db.Decimal(10, 2)
// Encrypted sensitive fields
plaidId String @unique
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([userId, createdAt])
@@map("transactions")
}
Implementation Checklist
Before marking development complete:
TDD Compliance (MANDATORY)
- All new code written using TDD (RED-GREEN-REFACTOR cycle)
- Tests written BEFORE implementation code
- Minimum 80% code coverage achieved (100% for financial logic)
- All acceptance criteria have corresponding tests
- Edge cases and error scenarios tested first
- No production data used in any tests
Code Quality
- TypeScript strict mode compliance
- Proper error handling implemented
- Input validation with Zod schemas
- Comprehensive logging without sensitive data
- Performance optimizations applied
Security
- Authentication/authorization implemented
- Sensitive data properly encrypted
- Rate limiting applied where appropriate
- Input sanitization and validation
- OWASP security guidelines followed
Testing (TDD-Enhanced)
- Unit tests cover all business logic (written first)
- Integration tests cover critical paths
- Error scenarios tested (network failures, timeouts, etc.)
- Financial calculation tests use Decimal precision
- Security tests validate access controls
- Performance testing completed (if applicable)
- iOS UI tests for user flows (if applicable)
- Mock data is clearly synthetic, never production-like
Documentation
- Code properly commented
- API documentation updated
- User guides updated
- Deployment notes documented
Requirements Validation
- All acceptance criteria met
- Success metrics can be measured
- Non-functional requirements satisfied
- Edge cases and error scenarios handled
Development Handoff
Once implementation is complete:
- Create feature branch following naming convention:
feat/<feature-name> - Link PR to requirements folder in description
- Include test evidence and screenshots (for iOS changes)
- Request code review from appropriate team members
- Ensure CI/CD pipeline passes all checks
Example Usage
# Start development on a specific feature
> Read requirements/user-authentication/ and start implementation
# Work on a specific user story
> Implement the "user authentication" story from requirements/login-signup-screen/user-authentication/user-stories.md
# Continue work on existing feature
> Continue development on requirements/spending-insights/ focusing on the widget integration
This chatmode ensures that requirements are properly translated into working, tested, documented code that meets ScheduPay's high standards for security, performance, and user experience.