A portable, provider-agnostic Socratic mentoring harness that helps students learn to code, reason, architect, review - and use AI well without becoming dependent on it.
Requires Node.js 20+.
npm install -g @open42/cli
open42 # on first run, it asks which provider you wantOr run it without installing:
npx @open42/cliPick your model:
# free & local, no API key (start a model first: ollama run llama3.1):
open42 --provider ollama
# or with a hosted key:
ANTHROPIC_API_KEY=sk-ant-... open42Prefer to run from source?
git clone https://github.com/Cimeci/Open42.git
cd Open42
npm install
npm start # builds, then launches the mentorOpen42 turns any capable LLM into a team of patient mentors instead of an answer machine. It is built in the spirit of 42's pedagogy - autonomy, peer-learning, learning by doing, and the conviction that productive struggle is how understanding is born.
The underlying method is maïeutics: the Socratic art of helping someone give birth to knowledge they already carry. The mentors help you understand and think; they don't just hand you an answer to copy.
LLMs make it trivial to get working code in seconds. For a learner that is a trap: copy-paste a generated solution and you ship working code and learn nothing. Worse, you build a dependence on the tool instead of the skill to command it.
Open42 has two goals at once:
- Learn to think - debug, reason, design, and review yourself.
- Learn to wield AI - go faster and further with AI while staying able to work without it.
Dependence is using AI to avoid thinking. Mastery is using AI to amplify thinking. Every interaction nudges the student from the first toward the second.
Each mentor is a specialised sub-agent with its own system prompt, sharing one foundation (the same guardrails, independence creed, and Socratic method):
| Mentor | id | Helps the student… |
|---|---|---|
| Socratic Tutor | tutor |
debug and reason through problems methodically. |
| Architecture Mentor | architect |
weigh design choices and trade-offs. |
| Code Review Mentor | reviewer |
critique their own code. |
| AI Literacy Coach | ai-coach |
decompose, prompt, verify, and judge when not to use AI. |
A router dispatches each student message to the right mentor. The default
HeuristicRouter is fast and free but keyword-based (English + French shipped);
for robust routing in any language, use the LlmRouter, which lets the model
classify the request.
Register your own mentors - the same way 42 builds learning from modular projects:
open42.registerMentor({
id: "sec-coach",
title: "Security Coach",
description: "Helps you find security issues in your own code.",
domains: ["review"], // reuse built-in domain prompts…
// …or supply a fully custom `prompt` and/or `extraInstructions`
routeKeywords: ["security", "vulnerability", "injection"],
});- Lead with understanding, not answers. Guide first; never hand over a copy-pasteable solution that lets the student skip the learning.
- One good question beats ten hints.
- You must understand what you ship. Output must never outrun understanding.
- Verify everything. AI (including the mentor) is sometimes confidently wrong.
- Protect the productive struggle, and hold the line warmly when a student begs for the answer.
Open42 ships a terminal app (built with Ink, like Claude Code and Codex). Bring your own model:
npm install -g @open42/cli
open42 # launches the mentor
# or, without installing: npx @open42/cliReplies stream in token by token, like Claude Code.
On first run it asks what you want to use and adapts:
- Anthropic (Claude) or OpenAI (GPT) - hosted, needs an API key
(
sk-ant-…/sk-…), saved to~/.open42/config.json(chmod 600). You can also setANTHROPIC_API_KEY/OPENAI_API_KEYand skip onboarding. - Local (Ollama) - free, no key. Run a model first (
ollama run llama3.1), then pick "Local". Perfect for students without an API budget. Local models automatically get a compact prompt so smaller models still follow the guardrails.
Pick non-interactively with open42 --provider ollama (or anthropic/openai)
and --model <name>.
What it looks like:
you › My recursive function returns undefined, I don’t understand why.
Tutor ›
Good question. Take the simplest case that already works: for n = 1,
What does the line that makes the recursive call actually RETURN? Read it aloud.
you ›
Each reply is badged with the mentor that answered (colour-coded). In-app commands:
| Command | Effect |
|---|---|
/help |
list commands |
/mentors |
list available mentors |
/mentor <id> |
pin a mentor (e.g. /mentor ai-coach) |
/auto |
resume automatic routing |
/lang <auto|fr|en> |
change the language |
/remember |
save a short summary of this session to local memory |
/memory |
show what is remembered |
/forget |
erase all memory |
/clear |
clear the conversation |
/quit |
exit |
Open42 can remember across sessions to help the mentor calibrate over time. It is deliberately conservative and private:
- You decide when to save, with
/remember(it writes a short, human-readable summary to~/.open42/memory/). - It stores understanding, not content: what you worked on and what's still shaky - never your solutions or code, never your API key.
- It never overstates mastery (no model "grading" you into "mastered").
- Past summaries are injected at the next session's start for continuity; read
them with
/memory, wipe everything with/forget. Plain Markdown you can open and edit yourself.
By default (auto), the mentor mirrors the language you write in - write in
French, get French; write in Spanish, get Spanish. Pick a fixed language with
open42 --lang fr (or en), the first-run prompt (press Tab to switch), or
/lang in-app. A fixed choice also localizes the interface (currently FR/EN) and
is saved to ~/.open42/config.json. Press Ctrl+C during a reply to
cancel it; twice when idle to quit.
Open42 ships a pedagogical eval suite so the teaching behaviour is measured, not assumed:
npm run eval # structural evals (no model needed)
OLLAMA_MODEL=qwen2.5:7b npm run eval # + behavioural evals, free and local
ANTHROPIC_API_KEY=... npm run eval # + behavioural evals on a hosted model- Structural evals check routing and that every mentor prompt still carries the guardrails (run with no model).
- Behavioural evals send real scenarios, including four adversarial "just give me the code" / jailbreak attempts, and verify the mentor engages the student and never dumps a solution.
Validated locally on qwen2.5:7b (a free 7B model with the compact prompt):
the mentor held the line on every scenario, including all four extraction
attempts. The guardrails work even on small, free, local models.
open42/
├── prompts/ # ← the heart: language-agnostic Markdown (source of truth)
│ ├── persona.md # who the mentor is
│ ├── guardrails.md # the core rules (lead with understanding, not answers)
│ ├── independence.md # using AI without depending on it (in every mentor)
│ ├── method.md # the Socratic loop
│ ├── calibration.md # gauging level & scaffolding
│ └── domains/ # debugging · reasoning · architecture · review · ai-literacy
├── src/ # TypeScript reference implementation
│ ├── open42.ts # the orchestrator (routes to mentors)
│ ├── mentors.ts # built-in mentors + extensible registry
│ ├── router.ts # HeuristicRouter · LlmRouter
│ ├── harness.ts # Maieutic - the single-mentor primitive
│ ├── prompts.ts # composes system prompts from the modules
│ ├── providers/ # provider-agnostic adapters (Anthropic, OpenAI, …)
│ ├── cli/ # the terminal app (Ink/React TUI)
│ └── types.ts
├── bin/open42.mjs # the `open42` executable
├── examples/ # library usage examples
└── scripts/ # builds the prompts into the bundle
You do not need TypeScript to use Open42. The pedagogy lives in prompts/.
Concatenate the foundation files plus the domains you want and paste the result
as a system prompt - that is the harness.
npm install @open42/cliimport { Open42, AnthropicProvider } from "@open42/cli";
const open42 = new Open42({
provider: new AnthropicProvider({ apiKey: process.env.ANTHROPIC_API_KEY! }),
rigor: "strict", // never reveal the solution
});
const reply = await open42.respond([
{ role: "student", content: "My recursive function returns undefined and I don't know why." },
]);
console.log(reply.mentor); // → "tutor" (auto-routed)
console.log(reply.content); // → a question, not a fixSee examples/ - including an offline inspector that needs no
API key and shows exactly what the harness composes and sends.
- Open
prompts/. - Concatenate
persona.md+guardrails.md+independence.md+method.md+calibration.mdand the domain files you want. - Paste the result as the system prompt of your favourite assistant.
Open42 is built for - and we hope by - the global student community. Better questions, new mentors, and translations are all welcome. See CONTRIBUTING.md.
MIT - free to use, fork, and adapt, including by schools.
