Twinny: Free, Private AI Coding in VS Code

Twinny: Free, Private AI Coding in VS Code

Twinny is an open-source VS Code assistant that lets you run local or hosted models for code completion, chat, edits, and reviews. Here is how to set it up and where it still falls short.

What you will learn

  • What Twinny is and why it exists as an open-source alternative to proprietary AI coding assistants.
  • How to install Twinny in VS Code and connect it to a local model like Ollama or a hosted API.
  • What you can do with it: code completion, chat, edits, and reviews.
  • One concrete example of using Twinny to refactor a function.
  • Where Twinny falls short compared to paid tools and what to expect.

What is Twinny, and why should you care?

Twinny is an open-source AI coding assistant for Visual Studio Code. It gives you code completion, chat, edits, and reviews — the same core features you get from proprietary tools like GitHub Copilot or Cursor — but with a key difference: you bring your own models. You can run models locally on your machine or connect to hosted APIs. Your code, your infrastructure, your rules. The project lives at twinnydotdev/twinny.

The problem Twinny solves is straightforward: many developers want AI assistance without sending their code to a third-party service. Privacy, cost, and control are the main drivers. With Twinny, you can use a local model like Llama 3 or Mistral via Ollama, or point it at a hosted provider if you prefer. The extension is written in TypeScript and is available on the VS Code Marketplace.

If you have been following the trend of open-source AI tooling, you might have read our take on OCP turning Claude Pro into an OpenAI API — Twinny is another step in the same direction: unbundling the model from the assistant.

How do you install and configure Twinny?

Getting started is quick. You install the extension from the VS Code Marketplace or from the command line:

code --install-extension twinnydotdev.twinny

Once installed, open the Twinny sidebar from the activity bar. You will be prompted to configure a provider. Twinny supports local providers like Ollama and LM Studio, as well as hosted APIs such as OpenAI, Anthropic, and others. For a fully local setup, install Ollama and pull a model:

ollama pull codellama:7b

Then in Twinny's settings, set the provider to Ollama and specify the model name. You can also set the API endpoint if you are running Ollama on a different port. That is it — you now have a private coding assistant.

If you prefer a hosted model, you can enter your API key in the settings. Twinny stores keys locally in VS Code's secret storage.

Twinny: Free, Private AI Coding in VS Code

For a deeper look at running local models with agents, see our article on Codex-bridge giving ChatGPT local hands.

What can you actually do with Twinny?

Twinny covers four main workflows:

  • Code completion: As you type, Twinny suggests completions inline. You can accept with Tab or dismiss. The completion model can be different from the chat model, so you can use a fast local model for completions and a larger one for chat.
  • Chat: Open the chat panel to ask questions about your codebase. You can reference files with @-mentions, and Twinny will include them as context. This is useful for explaining code or generating new snippets.
  • Edits: Select a block of code, right-click, and choose "Twinny: Edit selection". You can instruct the model to refactor, add comments, or fix bugs. The changes are shown as a diff you can accept or reject.
  • Reviews: Twinny can review your current changes (staged or unstaged) and provide feedback. This is handy before committing.

Here is a small example. Suppose you have a Python function that calculates the factorial of a number, but it is recursive and you want an iterative version. Select the function, open the chat, and type: "Rewrite this function iteratively." Twinny will propose a new version. You can then accept the edit.

For a more advanced workflow, you can combine Twinny with other tools. For instance, if you are running multiple agents, check out agentbox for running Claude Code agents in parallel.

Where does Twinny fall short?

Twinny is a young project. It is not as polished as Copilot or Cursor. The completion quality depends heavily on the model you choose; a small local model may be less accurate than a hosted one. The extension is actively developed, so you may encounter bugs or missing features. Also, setting up local models requires some technical know-how — you need to manage model downloads and hardware requirements.

Another limitation: Twinny does not have the deep codebase indexing that some proprietary tools offer. It relies on the context you provide via @-mentions or open files. For large projects, you may need to be explicit about which files to include.

That said, if you value privacy and control, Twinny is a compelling option. It is open source, so you can inspect the code, contribute, or fork it. The project is hosted on GitHub and welcomes contributions.

If you are interested in how AI is changing the nature of coding work, read our piece on AI coding better than most devs.

Should you switch to Twinny?

If you are a developer who works with sensitive code or wants to avoid subscription fees, Twinny is worth a try. It gives you a capable assistant without sending your code to the cloud. The setup takes a few minutes, and you can start with a small local model. For teams, you can standardize on a hosted model or a self-hosted endpoint.

However, if you need the most accurate completions and a seamless experience, proprietary tools still have an edge. Twinny is best for those who prioritize privacy and customization over out-of-the-box polish.

Give it a shot — install the extension, pull a model, and see how it fits your workflow. The project is open source, so your feedback can shape its future.

Source and attribution

GitHub Trending
twinnydotdev/twinny: Open-source AI coding assistant for VS Code. Code completion, chat, edits and reviews with local or hosted models. Your models, your infrastructure.

Discussion

Add a comment

0/5000
Loading comments...