DEV Community

William Wang
William Wang

Posted on

I Built an AI That Talks Like Warren Buffett — Here's What I Learned About Investing

It started with a late-night argument with myself.

I was staring at my brokerage account at 11 PM, finger hovering over the "Buy" button for a stock I'd seen mentioned on Twitter three times that day. My rational brain was screaming: "You haven't even read the 10-K." My emotional brain was whispering: "It's going up. You're missing out."

I didn't buy. But the experience stuck with me. What if I could have a conversation with someone like Warren Buffett in that moment? Not the real Buffett — but an AI that deeply understands his investment philosophy and could challenge my thinking the way he would?

That question led me to build the AI chat feature in KeepRule, and the journey taught me as much about investing as it did about AI engineering.

Why Simulate an Investment Master?

The investing world has a knowledge problem. Buffett's wisdom is spread across 50+ years of shareholder letters, hundreds of interviews, CNBC appearances, and books written about him. Charlie Munger's mental models span psychology, physics, biology, and economics.

Nobody has time to internalize all of that. But an AI can.

The idea wasn't to create a "stock picker bot" — those are dangerous and usually worthless. Instead, I wanted to build a thinking partner that could help investors pressure-test their ideas against proven investment principles.

Imagine asking: "I'm thinking about buying this company because revenue grew 40% last year" and getting a response grounded in Buffett's actual framework: "Revenue growth alone doesn't indicate a durable competitive advantage. What are the switching costs for their customers? What does the return on invested capital look like over a full business cycle?"

That's the kind of conversation that makes you a better investor.

The Technical Challenges (Where It Got Interesting)

Challenge 1: Building the Knowledge Base

The first thing I learned is that you can't just dump Buffett's shareholder letters into a prompt and expect coherent investment advice. The knowledge needs structure.

I spent weeks categorizing investment principles into taxonomies:

# Simplified version of our principle categorization
principle_categories = {
    "valuation": {
        "intrinsic_value": [...],
        "margin_of_safety": [...],
        "price_vs_value": [...]
    },
    "competitive_advantage": {
        "moats": [...],
        "brand_power": [...],
        "network_effects": [...],
        "switching_costs": [...]
    },
    "risk_management": {
        "circle_of_competence": [...],
        "position_sizing": [...],
        "leverage_avoidance": [...]
    },
    "behavioral": {
        "patience": [...],
        "contrarian_thinking": [...],
        "emotional_control": [...]
    }
}
Enter fullscreen mode Exit fullscreen mode

Each principle needed:

  • The original source (which letter, which interview)
  • The context in which it was stated
  • Related principles that often apply together
  • Counter-examples where the principle might not apply

This structured approach is actually what became the core of KeepRule's principle library — a searchable, organized collection of investment wisdom from master investors.

Challenge 2: Personality Consistency

This was harder than I expected. Early versions of the AI would swing between sounding like a textbook and sounding like a casual Reddit commenter. Neither felt like Buffett.

Buffett has a very specific communication style:

  • He uses folksy analogies ("It's like buying a farm...")
  • He references baseball ("I'm waiting for the fat pitch")
  • He's genuinely funny in a dry, self-deprecating way
  • He simplifies complex concepts without dumbing them down

Getting the AI to maintain this personality while also being genuinely helpful required careful prompt engineering and a lot of iteration. I tested it by feeding it questions from actual Berkshire shareholder meetings and comparing the AI's responses to Buffett's real answers.

The breakthrough came when I stopped trying to make the AI "be" Buffett and instead made it think using Buffett's frameworks. The personality follows naturally when the reasoning is grounded in the right principles.

Challenge 3: Avoiding Harmful Advice

This is where things get serious. An AI that talks about investing carries real risk. People could lose real money based on its responses.

I built several guardrails:

# Investment advice safety checks
SAFETY_RULES = [
    "never_recommend_specific_stocks",
    "always_emphasize_do_your_own_research",
    "flag_when_question_is_outside_competence",
    "warn_about_leverage_and_concentration",
    "distinguish_between_principles_and_predictions"
]

def validate_response(response: str, user_query: str) -> str:
    """
    Check AI response against safety rules before delivery.
    """
    if contains_specific_ticker_recommendation(response):
        response = add_disclaimer(response,
            "This discusses general principles, not specific investment advice.")

    if discusses_timing_or_predictions(response):
        response = add_disclaimer(response,
            "No one can reliably predict short-term market movements.")

    return response
Enter fullscreen mode Exit fullscreen mode

The AI should help you think better, not think for you. That distinction is critical.

What Building This Taught Me About Investing

Here's the unexpected part: building an AI investment advisor made me a significantly better investor. Not because I use the AI to pick stocks — but because organizing investment knowledge forced me to truly understand it.

Lesson 1: Principles Beat Predictions

While structuring Buffett's thinking, I noticed something: he almost never makes predictions. His shareholder letters rarely say "I think the market will do X." Instead, they describe principles that work regardless of what the market does.

"Be fearful when others are greedy" isn't a prediction — it's a decision rule. And decision rules are far more valuable than predictions because they're reusable.

Lesson 2: Most Investment Mistakes Are Behavioral, Not Analytical

As I categorized hundreds of investment principles, the behavioral category kept growing. Patience, emotional control, avoiding FOMO, thinking independently — these soft skills are mentioned far more often than valuation formulas or financial ratios.

Buffett himself has said that investing is "simple but not easy." The math is 8th-grade level. The psychology is PhD-level.

Lesson 3: The Best Investors Think in Systems

Buffett doesn't evaluate each investment in isolation. He has a system: circle of competence → competitive advantage → management quality → valuation → margin of safety. Every investment goes through this pipeline.

This is remarkably similar to how we build software. We don't write code without a framework. We don't deploy without a CI/CD pipeline. Why would we invest without a system?

This realization shaped the core philosophy behind KeepRule — giving investors a systematic framework built on proven principles.

Lesson 4: Inversion Is Incredibly Powerful

Charlie Munger's favorite mental model is inversion: instead of asking "How do I succeed?", ask "How would I fail?" and avoid those things.

I applied this to the AI design: instead of asking "What should this AI recommend?", I asked "What should this AI never do?" That inversion produced our safety rules, which turned out to be the most important code in the entire system.

In investing, inversion is equally powerful. Instead of "What stock should I buy?", ask "What would make me lose money on this investment?" If you can't answer that question, you don't understand the investment well enough.

Real User Interactions That Surprised Me

After launching the AI chat feature, I watched how people actually used it. A few patterns emerged:

The Confirmation Seekers: Many users came in wanting the AI to validate a decision they'd already made. The most valuable moments were when the AI pushed back — "Have you considered what happens to this company's margins if their largest customer leaves?"

The Framework Builders: Some users treated it like a mentor, asking broad questions like "How should I think about investing in banks?" These conversations were the longest and, based on feedback, the most valuable.

The Emotional Traders: During market dips, usage spiked. People wanted reassurance. The AI's consistent, principle-based responses ("Market drops of 10-20% happen roughly every 1-2 years historically; this is normal, not exceptional") provided genuine value.

What I'd Do Differently

If I started over, I'd:

  1. Start with fewer principles, more depth. Early on, I tried to cover every Buffett quote. Quality of understanding matters more than quantity of data.

  2. Build the evaluation framework first. Understanding how to measure whether the AI is actually helpful took too long. I should have defined success metrics before writing a single line of code.

  3. Talk to investors earlier. My first version was built on what I thought investors needed. The real needs were different — less "tell me what to buy" and more "help me think through this decision."

Try It Yourself

If you're an investor — or a developer interested in how AI can be applied to decision-making — I'd love for you to try KeepRule. Browse the investment principles library, chat with the AI about your investment ideas, and see if it changes how you think.

And if you're a developer building AI tools: remember that the most valuable AI doesn't replace human judgment. It strengthens it. The goal isn't artificial intelligence — it's augmented intelligence.

The best investment I ever made wasn't a stock. It was building a system that forces me to think before I act. Whether that system is an AI, a checklist, or a sticky note on your monitor, the principle is the same: decisions made with a framework beat decisions made with feelings.

Every single time.

Top comments (0)