How Skills Work in Open Interpreter: Building Reusable Function Libraries
Skills in Open Interpreter are standard Python functions stored in a dedicated directory that get automatically imported when import_skills=True, allowing you to build reusable function libraries accessible via the computer.skills namespace.
Open Interpreter treats skills as ordinary Python modules, enabling users to transform ad-hoc scripts into persistent, shareable libraries. This article explains the architecture behind the skills system and provides step-by-step instructions for creating reusable function libraries using the built-in wizard and manual module creation.
Architecture of the Skills System
The skills system consists of three core components: the Skills manager class, the NewSkill interactive wizard, and the profile configuration that enables automatic importing.
The Skills Class
Located in interpreter/core/computer/skills/skills.py, the Skills class manages the lifecycle of skill modules. It handles listing available skills via list(), searching via search(), and bulk importing via import_skills(). The class stores the path to the skills directory (defaulting to <repo_root>/skills) and executes all *.py files found there.
The NewSkill Wizard
Also defined in interpreter/core/computer/skills/skills.py (lines 57-124), the NewSkill class provides an interactive wizard for authoring skills. It guides users through naming the skill, recording sequential steps, and persisting the result as a Python module. The create() method initiates the wizard, add_step() records code blocks, and save() writes the final file to the skills directory.
Profile Configuration
Skills are enabled through profile configuration files such as interpreter/terminal_interface/profiles/defaults/the01.py. A profile sets interpreter.computer.import_skills = True and optionally customizes interpreter.computer.skills.path to point to a specific directory. Without this configuration, the skills system remains dormant.
How Skills Work in Open Interpreter at Runtime
Understanding the data flow helps clarify how reusable functions become available to the LLM during a session.
-
Startup: When
OpenInterpreterinitializes ininterpreter/core/core.py, it creates aComputerinstance. If the active profile setsimport_skills=True, thecomputer.skills.pathattribute is configured. -
Import: The first time the terminal interface or any LLM-generated code accesses
computer.skills, theimport_skills()method executes (triggered ininterpreter/terminal_interface/terminal_interface.py). This method walks the skills directory, concatenates all Python code, and executes it through the computer's Python executor. If a traceback occurs, it falls back to importing each file individually. -
Listing: Calling
computer.skills.list()returns available skill names formatted as function calls (e.g.,['weather_lookup()', 'file_search()']). This method simply reads the directory and appends()to each filename without the.pyextension. -
Execution: Because the modules were executed during import, the functions exist in the interpreter's global namespace. The LLM can invoke them directly:
weather_lookup(city="Paris"). -
Creation: When using
computer.skills.new_skill.create(), the wizard records steps and ultimately callssave(), which writes a new Python file to the skills directory. This file becomes available on the next interpreter start or after manually callingimport_skills().
Building Reusable Function Libraries
Creating persistent, shareable libraries involves enabling the system, using the wizard for interactive creation, or manually authoring modules.
Enabling Skills in Your Profile
Before creating skills, ensure your profile activates the system:
# interpreter/terminal_interface/profiles/defaults/my_profile.py
from interpreter import interpreter
interpreter.computer.import_skills = True # Enable automatic importing
interpreter.computer.skills.path = "./skills" # Directory for skill modules
This configuration mirrors the approach used in the01.py (lines 17-30).
Creating Skills with the Interactive Wizard
The wizard provides a guided interface for converting ad-hoc code into reusable functions:
# Start the wizard
computer.skills.new_skill.create()
The wizard executes the logic defined in NewSkill.create() (lines 62-73) and prompts for:
- Name: Setting
computer.skills.new_skill.name = "send_email"triggers the property setter (lines 78-84), validating the input. - Steps: For each step, the user executes code, then records it via
add_step("Description", code_string). This method (lines 100-112) stores the step as a markdown-formatted string. - Save: Calling
save()(lines 190-258) writes the Python file to<skills_path>/send_email.py, generating a function that contains the recorded steps.
Manual Skill Creation
For version-controlled libraries, manually create Python files in the skills directory:
# File: ./skills/data_processing.py
import pandas as pd
def clean_csv(filepath):
"""
Load and clean a CSV file by dropping NA values.
"""
df = pd.read_csv(filepath)
cleaned = df.dropna()
return cleaned
def summarize_column(df, column):
"""
Return basic statistics for a specific column.
"""
return df[column].describe()
These functions become available as clean_csv() and summarize_column() after the next import.
Importing Skills During a Running Session
If you add files to the skills folder while the interpreter is active, force a reload:
computer.skills.import_skills() # Re-imports all .py files in the skills directory
This executes the logic in import_skills() (lines 100-154), which concatenates all skill code and executes it through the computer's Python executor.
Code Examples
Listing and Calling an Existing Skill
# List all loaded skills
print(computer.skills.list())
# Output: ['weather_lookup()', 'file_search()']
# Call a skill directly (function exists in global namespace)
weather_lookup(city="Tokyo")
The list() method (lines 46-66) reads the skills directory and formats filenames as callable function names.
Authoring a Reusable Send-Email Skill
# Initiate the wizard
computer.skills.new_skill.create()
# ---- Wizard interaction ----
computer.skills.new_skill.name = "send_email"
# Step 1: Create message helper
code_step1 = """
import smtplib
from email.message import EmailMessage
def make_msg(to, subject, body):
msg = EmailMessage()
msg["From"] = "me@example.com"
msg["To"] = to
msg["Subject"] = subject
msg.set_content(body)
return msg
"""
computer.skills.new_skill.add_step("Create message helper", code_step1)
# Step 2: Send the email
code_step2 = """
def send(to, subject, body):
msg = make_msg(to, subject, body)
with smtplib.SMTP("smtp.example.com", 587) as s:
s.starttls()
s.login("me@example.com", "password")
s.send_message(msg)
"""
computer.skills.new_skill.add_step("Send using SMTP", code_step2)
# Persist the skill
computer.skills.new_skill.save()
After saving, the file ./skills/send_email.py is created. On the next interpreter start:
>>> send_email(to="bob@example.com", subject="Report", body="Here is the report.")
Manual Import of New Skills
# If you added files to the skills folder while running:
computer.skills.import_skills() # Forces re-import of all .py files
This executes the logic in import_skills() (lines 100-154), which concatenates all skill code and executes it through the computer's Python executor, falling back to per-file import if errors occur.
Summary
- Skills are standard Python functions stored as
.pyfiles in a configurable directory, loaded automatically whenimport_skills=True. - The
Skillsclass ininterpreter/core/computer/skills/skills.pymanages listing, searching, and bulk importing of modules. - The
NewSkillwizard provides an interactive interface for recording code steps and persisting them as reusable functions without manual file editing. - Profile configuration enables the system; setting
interpreter.computer.import_skills = Trueandinterpreter.computer.skills.pathactivates automatic loading. - Functions become globally available after import, allowing the LLM to invoke them directly by name without additional import statements.
Frequently Asked Questions
Where are skills stored in Open Interpreter?
Skills are stored as individual .py files in a directory specified by interpreter.computer.skills.path, which defaults to a skills folder in the repository root. The Skills class in interpreter/core/computer/skills/skills.py manages this directory, reading all Python files during the import process.
How do I enable automatic skill importing?
Set interpreter.computer.import_skills = True in your profile configuration file (such as interpreter/terminal_interface/profiles/defaults/the01.py). When this flag is active, the interpreter automatically executes all .py files in the skills directory at startup, making the functions available in the global namespace.
Can I create skills without using the interactive wizard?
Yes, you can manually create Python files in the skills directory. Each file should define functions that perform specific tasks. When the interpreter imports skills (either at startup or via computer.skills.import_skills()), it executes these files, making the functions callable. This approach is ideal for version-controlled libraries or complex multi-function modules.
What happens if a skill has an error during import?
The import_skills() method in interpreter/core/computer/skills/skills.py first attempts to concatenate and execute all skill code together. If a traceback occurs during this bulk execution, it falls back to importing each file individually, isolating errors to specific modules. This ensures that a single broken skill does not prevent other valid skills from loading.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →