Understand tokens
Bolt runs on Anthropic’s Claude Sonnet 4 AI model. To make this possible, Bolt uses tokens from Anthropic. A token is just a small piece of text: sometimes it’s a whole word, sometimes it’s only part of one. Every time you use Bolt, tokens are used in three main ways:- When you chat with Bolt
- When Bolt writes code
- When Bolt looks at your code to see what you changed
How you can reduce token usage
Every chatbox interaction you have with Bolt costs tokens, which affect your speed, cost, and project size limits. Bolt is built to keep token usage lean, and ongoing improvements continue to boost efficiency. At the same time, being mindful of how you use tokens is important for keeping projects smooth and cost-effective. This page lists the top ways to reduce token usage, including the following tips:- Plan your app
- Use Discussion mode
- Undo changes using the Version history feature
- Keep your prompts specific and focused
- Avoid repeated automated error fix attempts
- Add functionality incrementally
- Use the
.bolt/ignore
file - Reduce the size of your project
Plan your app
Planning your app before you start building saves time, tokens, and avoids headaches later. Start by deciding what type of app you’re making (website, web app, or mobile app) and who it’s for. List the key features you want, sketch out a simple design, and think about how users will move through the app. Examples:- A CRM might need lead capture, contact profiles, and search filters
- A portfolio site needs galleries, project descriptions, and contact links
- A habit tracker might include a daily checklist, progress charts, and reminders
To learn more, see our article on Planning your app.
Use Discussion mode
In Build mode, Bolt updates your code everytime you submit a prompt, which uses up tokens. To avoid unnecessary code changes, use Discussion mode when you want to get help, troubleshoot, or discuss plans, but don’t want to implement anything immediately. Discussion Mode uses approximately 90% fewer tokens than Build Mode.To learn more, see our article on Discussion mode tips.
Undo changes using the Version history feature
Use the Version history feature to restore your project to a previous state without consuming tokens. This is similar to an undo button that can take you back to any prior state of your project. If you’ve made a change you don’t like, rather than prompting Bolt to fix it, you can switch back to a previous version of your project without using tokens. This can save time and tokens if something goes wrong with your project.Keep your prompts specific and focused
When prompting, be clear and specific. See Prompting effectively for more information. Tell the model to focus on specific files or functions rather than the entire codebase.Avoid repeated automated error fix attempts
When an error occurs, Bolt gives you the option to try an automatic fix. Sometimes clicking it a second time will resolve the issue, but remember that each attempt uses tokens. Avoid clicking Attempt fix over and over, hoping for things to eventually work out. If Bolt can’t resolve the issue with automatic fixes, research the errors you’re getting and step in manually. You can also switch to Discussion mode to ask focused questions, explore solutions, and confirm a plan before the next fix.Add error handling to your project
If you find yourself stuck in an error loop, a useful strategy is to prompt Bolt to enhance error handling and implement detailed logging throughout the problematic area. When prompted to, Bolt excels at inserting robust error logs, even at a granular level, such as between functions or key steps. These logs provide valuable feedback that the AI can use to better understand the root cause of the issue. This additional logging also provides more precise information when the error occurs again. With this detailed feedback, Bolt can make more accurate adjustments to fix the issue.Add functionality incrementally
Before you focus on advanced functionality, make sure the basics of your app are in place.- Create your core pages: For example, a homepage, a dashboard, and a basic contact or help page
- Set up navigation: Make sure users can move between pages smoothly, like jumping from a leads page to a customer profile in a CRM
- Keep the design consistent: Use the same colors, fonts, and layout so the app feels professional and easy to use
- Start small, such as adding a form to capture leads or customer data
- Next, add functionality to store and display those records, like a simple customer list or profile view
- Then layer on search, filters, or analytics so users can find data quickly
- Test after each new piece to catch problems early and avoid breaking what already works
Use a .bolt/ignore
file
In the .bolt/ignore
file, you can list any files or folders that you want Bolt to exclude.
Instructing Bolt to ignore files can have unintended consequences, as Bolt is no longer aware of your entire project. This approach is powerful, but is only recommended for advanced users who can make informed decisions about what can safely be excluded, and can understand and resolve issues that may arise from this approach.
- In your Bolt project, switch to Code view to view your file list.
- Log in to your StackBlitz account.
- Either:
- In the
.bolt
directory, clickignore
to open the file in the editor. - If there isn’t an
ignore
file, right-click the.bolt
directory, then click New File…, then name the fileignore
.
- In the
- List the files you want Bolt to ignore. Provide the full path to the files, including directories. You can use as a wildcard. For example: to ignore all files in a directory called
test
, writetest/*
in yourignore
file. These files are now completely invisible to the AI, which frees up space in the context window.
Reduce the size of your project
As your project grows, more tokens are required to keep Bolt in sync with your code. Larger projects (and longer chat conversations) demand more resources for the AI to stay aware of the context, so it’s important to be mindful of how project size impacts token usage.Clean up unused files
Bolt uses a tool called Knip to perform a cleanup. You can run this when prompted by Bolt, or run it manually at any time. Before proceeding, back up your project using one or both of these methods:- In the top left of your screen, click the project title, then click Export > Download, or
- In the top left of your screen, click the project title, then click Duplicate.
npx knip --production --fix --allow-remove-files
Check the output in the terminal to see if the command ran successfully. This command removes unnecessary files from the codebase, which reduces the project size.
Split the project
An advanced technique is to split a large app into smaller parts, then connect them later outside of Bolt. A common approach is to keep the backend and frontend as separate projects. If you are new to development, proceed carefully or get help. If you decide to try this, keep in mind:- Plan what each part is responsible for.
- Decide how the parts will talk to each other, such as through an API.
- Keep each project in its own repository or folder.
- Write down how to set up and run each part.
Split files longer than 500 lines
It’s usually best to keep files less than around 500 lines. If you find that one of your files has grown larger than that, try the following prompt:Refactor [filename] by splitting it into multiple files. Add comments to understand what each new file is for. Keep the original file to act as a router for functions, so the app remains functional after the split.
Reset the context window
Resetting the context window clears the conversation history and reduces the information sent to Bolt. Before you do this, ask Bolt to summarize your chat history so you can keep track of important details. To do so, follow these steps:- In the bottom-left corner of the chatbox, click the plus icon, then click Discussion mode.
- Enter this prompt:
Please generate a short summary of our conversation so far
. - Check that Bolt’s response is accurate and contains everything you need.
- Copy the response out of Bolt and save it as a
.txt
or.md
file.
- In the top left of your screen, click the project title, then click Duplicate.
- If you have integrations active in the project, Bolt displays a dialog that confirms which integration settings it will copy. Click Duplicate in the dialog to continue.
- Bolt creates a new copy of the project, with an empty chat history.
- In the bottom-left corner of the chatbox, click the plus icon, then click Discussion mode.
- Click the plus icon again, then click Attach a file.
- Attach the
.txt
or.md
file you saved earlier. - Enter this prompt:
The attached file is a summary of the previous discussion about this project. Use it when working on future changes.
- Press
Enter
to upload the file and your prompt.