๐ The Final Piece of the Puzzle
We made it! Welcome to the finale of the Antigravity Beginner Series.
- Part 1: We built the Structure (Folders).
- Part 2: We designed the Face (Frontend & Safety).
- Part 3: We engineered the Heart (Backend & Anti-Ban).
Now, we need the “Team Handbook.” You see, AI (Gemini, ChatGPT, Cursor) has a fatal flaw: It has Amnesia. It forgets what it coded 20 minutes ago. It hallucinates. It gets stuck in loops.
Today, in Part 4, we create Workflow_Rules.md. This file teaches your AI how to “Save Its Game” so you never lose progress, and how to build the entire system without spending a single penny on API calls.
๐ง Concept 1: The “External Memory” (No More Amnesia)
When you code with AI for a long time, the chat context gets full. The AI starts forgetting your file structure. The Solution? We force the AI to write a diary.
We are introducing a file called AI_MEMORY.md.
- Before the AI writes code, it reads this file to know where it left off.
- After the AI finishes a task, it updates this file.
- Result: Even if your computer crashes or you start a new chat, the AI knows exactly what to do next.
โ๏ธ Concept 2: The “Simulation Hypothesis”
In the US, high-quality market data (Polygon.io, Alpaca) costs money. Even free ones (Yahoo Finance) have strict limits. The Antigravity Rule:
“If reality is expensive, live in the simulation.”
We force the AI to build the entire app using fake JSON data (mock_data.json) first. We only turn on the internet connection at the very last second.
๐ Action Item: Copy & Paste This!
This is the most important file for your sanity. Create Workflow_Rules.md inside your ./agent/ folder.
๐ Copy this content into your file:
# ======================================================
# ๐ Antigravity Workflow Rules (US Market Edition)
# Version: 2.1
# Context: Development Lifecycle & Memory Sync Protocol
# ======================================================
metadata:
trigger: "always_on"
description: "Orchestration of Development Lifecycle, Context Preservation, and Logic Sequencing."
system_role:
title: "Technical Project Manager (TPM)"
core_objective: "Orchestrate the project to minimize 'Cost' (API Calls & IP Risk) and prevent Context Loss."
primary_directive: "Maintain the project state in './agent/AI_MEMORY.md' continuously."
# ------------------------------------------------------
# 1. The Development Lifecycle (4-Phase Architecture)
# ------------------------------------------------------
lifecycle_phases:
phase_1_blueprint:
name: "The Blueprint (Planning)"
goal: "Define the Project Roadmap and Architecture."
api_rule: "STRICTLY NO API calls allowed. Pure planning only."
phase_2_contract:
name: "The Contract (Static Data & Schema)"
goal: "Create 'schemas.py' and Mock Data."
actions:
- "Manually fetch *one* real dataset (e.g., OHLCV for AAPL/TSLA) and save it to './agent/mocks/market_data.json'."
- "STOP: Do not create dynamic fetchers yet. Use this static file for all initial dev."
rationale: "Simulation First approach to save API costs."
phase_3_core:
name: "The Core (Logic Implementation)"
goal: "Implement business logic (Indicators, Signals)."
constraints:
- "Logic must accept the 'DataProvider' interface."
- "Apply 'API Last' logic (e.g., Don't fetch price if user has no purchasing power)."
phase_4_shell:
name: "The Shell (UI & Integration)"
goal: "Connect the User Interface."
constraints:
- "UI must start in 'SIMULATION' mode by default."
- "Visual safety checks must be active."
# ------------------------------------------------------
# 2. Micro-Update Protocol (Context Preservation)
# ------------------------------------------------------
memory_protocol:
objective: "Prevent context loss (Amnesia) during complex tasks."
instruction: "Update './agent/AI_MEMORY.md' FREQUENTLY, not just at the end."
trigger_events:
- "Before writing a new source file."
- "After fixing a bug or refactoring."
- "When a logical step (e.g., 'Validation Logic') is complete."
logging_command: "Action: Updating Memory..."
# ------------------------------------------------------
# 3. Debugging & Safety Protocols
# ------------------------------------------------------
safety_protocols:
anti_freeze:
rule: "If a loop runs > 10 seconds, log progress immediately."
freeze_recovery:
action: "If the session crashes or hangs, read './agent/AI_MEMORY.md' immediately to resume context."# ======================================================
# ๐ง Antigravity Project Memory (US Market Edition)
# File Path: ./agent/AI_MEMORY.md
# Context: External Memory & State Persistence
# ======================================================
metadata:
last_updated: "(Init)"
description: "Primary storage for AI context to prevent amnesia."
# ------------------------------------------------------
# ๐ Current Status
# ------------------------------------------------------
current_status:
phase: "Not Started"
mode: "SIMULATION (Default)"
api_usage: "0 calls"
financial_exposure: "$0.00 (Safe)"
# ------------------------------------------------------
# โ
Recent Accomplishments (Checklist)
# ------------------------------------------------------
recent_accomplishments:
- task: "Project Rules Loaded from ./agent/"
completed: false
- task: "Phase 1 Blueprint Initiated"
completed: false
# ------------------------------------------------------
# ๐ง Active Context (What are we doing RIGHT NOW?)
# ------------------------------------------------------
active_context:
state: "Idle"
description: "Waiting for user instruction to begin Phase 1 (Roadmap Definition)."
# ------------------------------------------------------
# ๐ Immediate Next Steps
# ------------------------------------------------------
next_steps:
- priority: 1
action: "Define the development roadmap based on US Market constraints."
- priority: 2
# [Localization Note] 'Pykrx' replaced with 'yfinance' for US Market
action: "Create Mock Data for yfinance/SEC API to avoid early blocking."๐ You Are Ready to Launch!
Congratulations! You have successfully installed the Project Antigravity Framework.
Let’s recap what you have built:
.agentrules: The Compass that points to your rules.Frontend_Rules.md: The Safety Guard that prevents accidental trades.Backend_Rules.md: The Ninja that avoids IP bans.Workflow_Rules.md: The Manager that saves your progress.
What now? Go back to your AI (Cursor/Gemini) and type the System Boot Command from Part 1. The AI will read all these files, initialize its memory, and ask you:
“I am ready. What is your trading strategy?”
Welcome to the world of Vibe Coding. The market is waiting. ๐