Search⌘ K
AI Features

File Reference and Running Commands in OpenCode

Explore how to launch OpenCode within a project directory, reference specific files using fuzzy search, and run shell commands to inspect or modify your codebase. Understand how these core features enable continuous, context-aware conversations that link code and command output, helping you navigate and manage unfamiliar repositories effectively.

Now that you know what OpenCode is and why it exists, let’s use it. This lesson covers the basic workflow: start OpenCode, send a prompt, and let it read your project files. We won’t cover refactoring, complex workflows, or advanced commands yet. The goal is to get familiar with the core loop.

How do we launch OpenCode?

OpenCode is designed to be launched from within a project directory. This isn’t a cosmetic detail; it’s fundamental to how the tool operates. The moment we start OpenCode, it scans the current directory and treats it as the working context. Everything it does, from reading files and answering questions to proposing changes, is scoped specifically to that project.

We navigate to our project in the terminal and run:

opencode

This starts the interactive terminal user interface (TUI). What appears next looks like a chat interface, but we shouldn’t think of it as a traditional chatbot. Unlike browser-based tools, this interface is directly connected to our filesystem and repository state.

Once OpenCode starts, it keeps running until you quit the session. From that point on, you interact with the agent in a single continuous session. ...