Skip to main content

Command Palette

Search for a command to run...

Prompt Engineering 101: How to Give Your Mobile AI a Memory (and a Brain)

Updated
2 min read
Prompt Engineering 101: How to Give Your Mobile AI a Memory (and a Brain)
G
I'm a Senior Software developer who loves solving real-world problems and building meaningful products 💡 I currently focus on crafting clean, user-friendly experiences using React Native ⚛️ I enjoy working on challenging projects and constantly learning new things — whether it’s exploring a new framework or diving deeper into existing ones. This space is where I share my journey, the issues I tackle, and the lessons I pick up along the way 🚀

I used to think that "Chatting" with an AI was like a real conversation. But as a developer, I’ve realized it’s more like a movie script that we keep rewriting and resending every time the user types a new message.

Every time you ask a question, the app sends a massive block of text containing the rules, the history, and the new question.

  • System Prompts are the "hidden rules."

  • Conversation History is the "fake memory."

  • Prompting Techniques are how we train the AI on the fly.

The "Memory" Illusion

Since LLMs are stateless (they forget everything the moment they finish a sentence), we have to feed the entire history back to them.

User: "What color is salt?" AI: "White." User: "How do I cook with it?"

To the AI, "it" means nothing. So, our app actually sends: [System Rules] + [User: What color is salt?] + [AI: White] + [User: How do I cook with it?] Now the AI sees the context and knows "it" = "salt."

Zero-Shot Prompting (The "Just Do It" approach)

You ask a task with no examples.

  • Example: "Translate 'Hello' to Spanish."

  • The AI relies purely on its pre-trained "common sense."

Few-Shot Prompting (The "Follow My Lead" approach)

You provide a few examples to show the AI the format you want. This is massive for mobile devs who need specific data formats like JSON.

  • Example: * Input: Apple -> Output: Fruit

    • Input: Carrot -> Output: Vegetable

    • Input: Chicken -> Output: [Your turn...]

  • The AI sees the pattern and follows it perfectly.

In a React Native app, this means our messages state array is the most important part of the app.

  • Token Management: Every time we resend the history, we use more Tokens. If the chat goes on too long, we have to "truncate" (delete) the oldest messages so we don't hit the Context Window limit or crash the phone's RAM.

  • Thinking Mode: Want your app to be smarter? Just inject a hidden instruction: "List the pros and cons before giving a final answer." The user sees a "smarter" AI, but it's really just a prompt trick!

AI for Mobile Developers: Learning Local LLMs

Part 5 of 7

AI for Mobile Developers: Learning Local LLMs is a public learning journey documenting how a React Native developer explores practical AI integration for mobile apps. This series focuses on understanding how Large Language Models work and how they can run directly on mobile devices using local inference. Instead of deep AI theory, the goal is to learn from a developer perspective — experimenting with tools, running models locally, and eventually integrating AI features inside mobile applications.

Up next

Beyond the Chatbox: Structured Data and the Art of Prompt Compression

I’ve spent the last few posts learning how to talk to an AI. Now, I’m learning how to make the AI talk back in a way my code understands. If I want to build a weather app, I don't want a poem about ra