Skip to content
Back to home
Feature

How PocketCode's AI Works Under the Hood

A technical look at how we designed PocketCode's AI assistant: inline suggestions, contextual chat, and tools that reach the app's modules, with your own provider.

Updated:
5 min
By Pelayo Naredo
How PocketCode's AI Works Under the Hood

How PocketCode's AI Works Under the Hood

PocketCode's artificial intelligence isn't a generic chatbot glued to an editor. It's an integrated system that understands your project, your code, and the modules you're using. In this post, we'll tell you how we built it.

General Architecture

The AI system has three main pieces:

1. Inline suggestions (ghost text)

While you type, the editor can show a grey suggestion after the cursor, powered by the AI provider you connected. It works separately from the language servers, which give completions and diagnostics locally.

What it does, and what it doesn't:

  • A window around the cursor: the request carries up to 2,000 characters before the cursor and 500 after it (Fill-in-the-Middle style), plus the language. It doesn't send the rest of the project.
  • Short, raw code: the model is told to answer with code only, at most 10 lines, or to answer nothing when nothing fits.
  • On by default, with a provider: it needs a provider with a key or sign-in, the data notice you accept the first time, and the Auto suggestions and Code completion switches (Settings → AI, both on by default). It switches itself off in very large files.

2. Contextual Chat

The AI chat isn't a simple prompt-response. For each turn the app builds a context and sends it with your message:

  1. The open file (up to 4,000 characters), its language and the project name
  2. A list of paths and a map of the repository
  3. The project memory (up to 4,000 characters), if there is any
  4. Your @ mentions, the files you attach and the results of the tools

This means you can ask "what does this function do?" without having to copy and paste code. Before a prompt leaves the device, common key shapes (OpenAI, Anthropic, Google, GitHub, AWS keys and so on) and your stored secrets are masked: a safety net, not a guarantee.

3. Module Tools (Tool Calling)

This is the most powerful part. The app declares 84 tools, and a normal chat offers up to 79 of them in 14 categories (files, terminal, Git, database, API, SSH, deploy, the Dev Browser and more) so the AI can work with the app's modules. A representative sample:

ToolWhat it does
create_fileCreates files in your project
run_in_terminalRuns a command in the local shell
db_queryRuns queries against the database
design_listLists and reads visual-designer projects
git_statusChecks Git status
read_fileReads project files
semantic_searchRanks code by the keywords of a plain-language question
grep_searchSearches the codebase for an exact string or pattern

When you tell the AI "create a ViewModel for the user list", it doesn't just generate code: it can create the file in the folder you ask for and edit the files that need the change.

Security

What the agent may do is decided by an access level with five steps: No tools, Read only, Ask first, Auto-edit (the default: it writes files on its own and asks before running commands) and Full access.

  • Always asks for what leaves your device: a git push, a deploy, an API request or an ssh command waits for your OK at every level, unless you switch that protection off in AI Tool Permissions.
  • Risk check on commands: terminal commands are classified before they run, and a catastrophic one never runs. It is defence in depth, not a sandbox.
  • Per-tool permissions: in Settings → AI → AI Tool Permissions you can deny any tool for a provider or a model.
  • Limits: a command waits 30 seconds by default (120 at most), and read_file refuses files over 5 MB.

Supported Models

PocketCode works with multiple AI providers under a BYOK (bring-your-own-key) model, with ChatGPT and GitHub sign-in where the provider supports it. PocketCode is not an AI provider: every request goes directly from the device to the provider you pick, and usage is billed by the provider under their policy.

  • Gemini (Google) — API key only
  • OpenAI — API key, or sign in with your ChatGPT account through the bundled Codex CLI (64-bit ARM phones only)
  • Anthropic Claude — API key only (sk-ant-…)
  • GitHub Copilot — sign in with your GitHub account
  • Custom (OpenAI-compatible) — any /v1 endpoint: OpenRouter, Groq, DeepSeek, LM Studio, Ollama or your own server. Plain HTTP works only for localhost; an Ollama or LM Studio on your network needs HTTPS or a tunnel.

The model list isn't fixed: each provider's list is read live from the provider, and the app keeps a small fallback list for when you have no network or no key.

Every provider is free. PocketCode never charges for model access; the paid tier is for its own engines and tools (Swarmcode, Cortex and AI Office are Pro, and so is Cloud Sync).

Users connect their account or API key in Settings → AI → API keys.

Conclusion

PocketCode's AI isn't a bolted-on component — it's an integral part of the development experience. Every app module (terminal, database, designer, Git) is connected, and the AI can reach all of them through tools, under the access level you choose.

You can see the complete development status in our status post.

The tool behind this article

AI Assistant

Ready to try PocketCode?

Download the app and start coding from your mobile.