A prompt to use an AI to define a curriculum and guide that will teach you how to write an OS from hello world to a greeter, user system and processes
NOTE! This does not make an AI generate an Rust based operating system, it generates a curriculum/guide which YOU will be able to follow to write a Rust based OS, i dont condone vibecoding apps, and this does not do that!
This prompt will (in order):
- Ask the user for basic project information (like name, editor, os etc)
- Make the AI research concepts, ideas and implementations
- Ask the user what path they want to go in the big underlying decisions (like starting with a single core and implementing multithreading in the future, or doing multithreading from the start, or deciding between monolith vs microkernel)
- Generate an internal plan for the full guide
- Use said plan to generate a full guide which should be enough by itself to learn how to implement an os
- Go into assist mode, where it assits the user by elaborating, explaining and helping the user as they work through the full guide
The user can at any time in the process of following guide, request more features to be added.
The AI also saves the users progress through the guide in a seperate file so the user can whenever say "well pick it back up tomorrow" and be able to resume whenever flawlessly.
What the underlying AI requires for this prompt to work well:
- Access to the internet, to research the concepts etc
- Access to some sort of file or text saving. It needs to be able to write long texts (such as the guide), save them, and reread or edit them later
- Good prevention of hallucinations, they are assumed that the AI does this by itself, otherwise some parts of the guide may be incorrect or hallucinations'
To start, paste the following prompt into the AI (If the ai has saved memories of you regarding coding prefrences or operating system development, tell it to not refrence said memories in this specific chat):
# The Rust OS Development Mega-Prompt
## Before the content
- You (the AI agent / assistant receiving this prompt) must, using the tools at your disposal (memory, files, notes, task trackers, whatever exists), store this entire prompt and keep it available for the whole project. Re-read it whenever you are unsure what to do, when the session is long, or when the user asks for changes. Do not rely on the conversation context alone.
- Anything written as "the AI" or "you" in this prompt is directed at you, the agent currently assisting the human. "The user" is the human building the OS.
- Everything this prompt asks for, implies, or says to do in specific situations is binding for the entire project, not just the first message.
- **Platform requirement:** This project needs you to deliver two documents (a .md file, a page, a separate workspace, or whatever your platform calls it) and to update them later. If you cannot produce and update documents, tell the user that your platform is not suitable for this prompt, and stop.
## The two documents
1. **The planning document (AI-facing).** It contains your research, the links to your sources, the decisions made, the curriculum plan, and the script you follow when planning further. You link the user to it, but it is not what the user follows.
2. **The user guide (user-facing).** This is the document the user follows through the entire project. It is written from the planning document, after the planning is finished. The standard it must meet is described in Part 2.
## Overview of the flow
1. **Intake:** Ask the user a few basic questions.
2. **Research and planning:** Research silently, ask the user about the major design decisions, and write the planning document.
3. **Writing the guide:** Write the complete user guide from the planning document and supply it to the user.
4. **Support:** The user follows the guide on their own. You elaborate, explain, and provide more code on request. You do not drive the process step by step.
5. **Further features:** The user may request extra features at any time. You plan them and update both documents.
---
## Intake (before any research)
Before searching, ask the user these questions in one message:
- What should the project be called?
- Which host OS will they develop on?
- Which editor or IDE will they use?
- What pacing do they want (slow and thorough, moderate, fast), and anything about how they want to learn?
- What have they already installed (Rust, QEMU, toolchains)?
Add any other question you genuinely need, but keep it short and don't ask what you can find out yourself. Store the answers with the project state (see "State and tracking"). They appear in the guide's header (see "Front matter").
**Mandatory follow-up on the host.** The host's details can change the whole plan, so you must always ask the follow-up that applies. Do not skip it, and do not assume the answer:
- **If the host is a Mac, you must ask whether it is Apple Silicon (M1, M2, M3, M4, ...) or Intel**, and offer "not sure" with a short way to find out (Apple menu, About This Mac). This decides whether the x86_64 OS runs natively or under slower software emulation, and which tool builds apply. Research the consequences (emulation speed, tool availability, acceleration options) and explain them to the user in plain language in the decisions message.
- If the host is Windows or Linux, ask the equivalent question that changes the plan (for example whether the user will use WSL on Windows, or which distribution on Linux, and whether the CPU is x86_64 or ARM).
Ask this follow-up with the intake if you can, and at the latest in the decisions message. It must never be missing from the user's setup table.
## The user
- Comfortable with normal Rust (think axum services, CLIs).
- Assume little to no knowledge of `no_std`, `unsafe`, or bare-metal Rust.
- Assume no knowledge of operating system concepts (booting, memory, paging, interrupts, scheduling, drivers, filesystems, syscalls, etc.). Every concept must be introduced before it is used.
- Knowledge and active use of git are assumed. Do not teach it.
---
## Part 1: Research and planning
Do this silently, using the tools at your disposal. Search the web and use what you find to plan a curriculum for building an operating system from scratch in Rust, targeting **x86_64**. The curriculum starts with setting up the environment (toolchain, QEMU, and everything else needed).
### Source priority (very important)
The early research decides what features the OS needs and in what order, and everything else depends on it. Use reliable sources first, especially when determining the feature list and the architecture of the curriculum.
1. **The OSDev wiki (osdev.org) is the primary source.** Prioritize it. It covers the breadth of what a larger OS needs.
2. **Philipp Oppermann's "Writing an OS in Rust" blog is the secondary source.** Use it as a reference for pacing, teaching style, and the early phases. It is somewhat dated and was not designed for an OS of this scope, so verify anything you take from it against current documentation before using it.
3. Then: official documentation for crates and tools, solved Reddit threads, solved Stack Overflow questions, solved GitHub issues, and any other source that provides what you need.
When sources disagree, prefer the more authoritative and more recent one, verify with a third source, record the conflict and how you resolved it, and tell the user about significant conflicts.
### Research rules
- Use modern tools, crates, and methods. Do not use dated libraries when a modern alternative exists. Check what is current, don't assume.
- Do **not** hardcode specific libraries or approaches in advance. Figure them out during planning.
- **Do not hallucinate.** Fact-check everything: crate APIs, versions, flags, target specs, memory addresses, register behavior. If you can't verify something, say so, and don't present it as fact.
- **Use sources in your own words.** Learn from blogs, wiki pages, and other sources, and write everything in your own words. Never copy their text or large code blocks verbatim.
- **Features found during research:** If you discover during research that the OS needs a feature that wasn't listed but is crucial for it to work as described, include it in the base curriculum. Do not treat it as an optional extra feature. Tell the user what you added and why.
- **Stable phase IDs and dependencies:** Give every phase a permanent ID (P00, P01, ...) that never changes, even when phases are inserted or reordered. New phases get new IDs, and existing IDs are never renumbered. For each phase, record which phases it depends on. Keep a changelog of curriculum changes. Use the dependency map to answer "can I add X now?" and to place new phases correctly.
- **Version pinning:** Pin the Rust toolchain (for example with `rust-toolchain.toml`) and all dependency versions, and record the date the research was done. If something later stops matching the guide (a crate changed, a nightly broke), re-verify it with your tools, fix both documents, and record the change. Do not let anything silently float to a newer version.
- **Effort and difficulty notes:** Mark each phase with an honest difficulty (1 to 5) and rough time expectation. Warn up front about the hard ones (for example paging, context switching, user mode, running ported programs like Doom) and about phases that will likely take much longer than the ones before them.
### Decisions
Never pick arbitrarily when there is a real design choice (for example bootloader, kernel style, task model, allocator type, filesystem, password hashing). For every real choice, prepare:
- an easy-to-understand explanation of the options, written for someone with no OS background,
- the pros and cons of each,
- your own recommendation and why it fits this user.
Then handle it like this:
- **Decisions that shape the whole curriculum** (bootloader, kernel style, task model, single-core vs multicore, and similar): ask the user before you write the guide, in one message, in this format:
1. **You must start with a short research summary.** A few plain-language bullets on what the initial research found and which direction it points, with source links. It informs the choices and does not replace them.
2. **Echo the intake back** as a small table (project, host, editor, target, pacing, installed tools, and the host follow-up answer), so the user can correct anything.
3. **One numbered section per decision:** a title, a one-line question, and lettered options. **You must mark exactly one option "(recommended)" in every decision.** Each option gets a short plain-language description and a few bullets of ups and downs. Say why the recommended option suits this user's pacing and setup.
4. **You must include every question whose answer changes the plan,** even if it isn't a design decision. The host-details follow-up from the intake (Apple Silicon or Intel for a Mac host, and the equivalents for other hosts) is always one of them if it hasn't already been answered. Offer a "not sure" option and say how to find out.
5. **Keep it to the decisions that truly shape the curriculum** (usually four to six). Everything else becomes a phase-local decision point.
6. **End with an answer template** the user can fill in with letters, plus an optional "Anything else?" line.
7. **Do not start writing the guide until the answers are in.**
- **After the answers:** confirm the final decisions in a table, and explain in plain language what they mean for this user's setup (for example emulation speed, which tools are needed, what is postponed to a later phase). Pin the versions you verified, state the date, and say what comes next (the guide).
- **Decisions local to one phase** (for example the allocator design, the filesystem, the hashing algorithm): write them into the guide as a **Decision point** box at the place they arise, with the options, the pros and cons, and the recommendation. The guide continues with the recommended option and says how the user can switch (the user tells the AI, which adapts the guide). Record every decision, with its reasons, in the planning document.
### Pacing and philosophy
- Follow a pacing similar to Philipp Oppermann's blog. Do not rush toward a finished result.
- **Start small and build up.** Begin with a very basic build that compiles, runs, and displays some output. Add features in steps on top of it.
- **Do it simply first, then perfect it.** The user wants to see results. Do not make the user write hundreds of lines before seeing any output when a small version can show the feature working. For every feature:
1. Start with the smallest working version. Have the user run it and see it work, and let that moment land.
2. Then explain the flaws of that version, one at a time: what is wrong, why it matters, and what fixes it.
3. Improve the code step by step to address each flaw, explaining each change, until the feature reaches the quality the final OS needs.
Never introduce dependencies, files, modules, or abstractions before the step that needs them. Where useful, say explicitly in the guide what **not** to build yet.
- **Evolve, don't predesign.** Early versions of a feature may be simple, hardcoded, or tightly coupled to the kernel. When the curriculum later introduces the right abstraction (drivers, tasks, processes, a filesystem, and so on), go back and migrate the earlier hardcoded code onto it, instead of leaving two parallel versions. Each such migration is its own step with a clear explanation:
- what the old approach was,
- why it no longer fits,
- how the new abstraction replaces it,
- what the user should see afterwards (the behavior stays the same, the structure improves).
Plan these migrations from the start, so that early shortcuts are deliberate and known to be temporary. Mark each shortcut in the guide as "Temporary shortcut: ..., replaced in Phase X", and mark the replacing phase with a "Migration" note.
- **`unsafe` follows the same pattern.** Early on it is fine for `unsafe` to appear in a direct, simple form. Every `unsafe` block must come with a plain-language statement of the invariant that makes it sound. In the "perfecting" part of the step, refactor it into a small safe API that hides the `unsafe` and enforces that invariant, and explain why that is better. Teach this habit from the first `unsafe` block so it is normal by the time the codebase grows.
### Curriculum structure
- **Phases:** The curriculum is divided into phases, like a blog series (for example: initial hello world, allocation, interrupts, ...). Each phase adds a feature and **must result in a compiling, working program** the user can run and observe.
- **Steps:** Each phase contains steps.
- If a phase can be split into parts whose progress can be visualized (for example with prints, screen output, or a log), each step should also compile and run, and show its progress.
- If a phase can't be split that way because the parts can't run without each other, steps don't need to compile individually. Only the end of the phase has to.
### Scope of the standard curriculum
It should end with a working operating system that boots, allocates memory, and has a userspace / user system where you can log in. Include at least the following, and add any features in between that a coherent OS needs (the list below is a floor, not a ceiling):
- Environment setup first: toolchain, QEMU, build and run workflow, debugging setup.
- Booting on x86_64, a minimal freestanding kernel, and basic output (framebuffer / VGA text / serial).
- Panic handling, logging, and testing infrastructure.
- CPU exceptions, interrupts, timers, and the interrupt controller.
- Memory: physical frame allocation, paging and virtual memory, kernel heap and allocator.
- Tasks / processes and a scheduler (cooperative first, then whatever fits), context switching.
- **Modular drivers:** a driver framework where drivers can be enabled, disabled, and added without rewriting the kernel (keyboard, timer, serial, disk, and so on).
- A filesystem layer (VFS-style abstraction plus at least one concrete filesystem) and storage driver.
- System calls and the kernel/user boundary, user mode, and loading and running user programs.
- A user system: users, login, permissions as far as sensible.
- **Greeter and TTY/shell as interchangeable tasks:**
- The greeter (prompts for user and password) and the TTY/shell are standard tasks, not hardcoded.
- The system can be configured to boot into a greeter, which can then be configured to start a shell task, or something else like Doom or Snake, after login.
- Alternatively, the system can be configured to boot straight into something else.
- A shell with command parsing and basic commands (for example `echo`, a fastfetch-style system info command, and other fitting basics).
- System integration (startup ordering, error handling, cleanup), and a wrap-up: a reference of what was built, how the parts connect, and where to go next.
### Debugging toolkit (taught early)
Operating system bugs are hard: there is often no output, a silent reboot, or a triple fault. In the setup phase of the guide, teach the user the tools to deal with this, before they are needed:
- Serial output as a logging channel.
- QEMU's debug and monitor options.
- Attaching GDB to QEMU.
The guide gets a dedicated "When <project> hangs or reboots" section (see "Back matter") that grows as phases add new ways to crash (interrupts, paging, stack overflows, context switching).
### The planning document (AI-facing)
After the research, write the planning document. It is for you, not for the user to follow. Link the user to it, and tell them what it is. Start it with a header block (project, host, editor, pacing, target, research date), then these sections, in this order:
1. **Planning script:** the exact process you follow when planning anything further (extra features, curriculum changes, re-verification, corrections). Include the source priority, the research rules, the decisions procedure, the pacing and philosophy rules, the guide's phase layout, the checklist for placing a new phase using the dependency map, the verification rule, the support rule, and the process for updating both documents. Write it so that you, or another AI picking up the project later, can plan a new feature identically without the original conversation.
2. **Research findings:** by topic, in your own words, each with the links to the sources used. Include what conflicted, how you resolved it, and what you couldn't verify.
3. **Architectural decisions:** a table (decision, options considered, choice, reason), plus a list of the decisions intentionally left to a later phase's decision point.
4. **Curriculum:** every phase with its ID, dependencies, difficulty, time, a short description, hard warnings, and temporary shortcuts.
5. **Dependency map:** a diagram of how the phases depend on each other.
6. **Temporary shortcuts and planned migrations:** a table (shortcut, why acceptable now, replaced in).
7. **Debugging strategy.**
8. **Version pins:** toolchain, crates, tools, and the date they were verified.
9. **Changelog:** dated entries for every change to the curriculum, decisions, or versions.
Keep it updated whenever anything changes.
---
## Part 2: The user guide
Once the planning document is complete, write the user guide from it and supply it to the user.
### The standard it must meet
- **The guide is complete.** It must be a full guide, similar to one of the blog-based guides, that the user can follow to implement everything the OS needs, without going to external links. Every phase is written in full. An outline, a "baseline", or summaries of later phases do not meet this standard.
- **Quality bar:** the guide must be of equal or higher quality than Philipp Oppermann's blog. The user must not need an AI alongside it to implement the entire OS. The guide alone is enough. The AI is only a tool for elaboration.
- **Every concept is explained** so that it is understandable to someone with no OS background, before it is used. Do not assume knowledge and do not defer important explanations to an external link.
- **Real implementation guidance.** Every phase has concrete implementation steps with pseudocode and the commented snippets needed for everything the pseudocode can't express. A phase made only of explanations and "we will do this later" is not finished.
- **Visuals:** include diagrams and flow charts inside the guide to visualize concepts (memory layouts, page tables, boot flow, interrupt handling, scheduling, driver architecture, and so on). Use what your platform supports (images, Mermaid, SVG). Plain-text diagrams in code blocks are fine and portable. Prefer clear and correct over decorative.
- **Clear flow:** it must always be clear from the document itself what to do next. The user should never need to ask the AI "okay, I did this, what is the next step?". Each phase ends with a short "what's next".
- **Own words:** write it in your own words, never copying sources.
- **Size:** if the guide is too large for one output, write it in parts (or as multiple files) with a table of contents linking to each part, and keep going until every part is written, without waiting to be asked. Later edits then only touch the affected part.
### Front matter
Start the guide with a header block (project, status and the date it was verified, host, editor, target), a table of contents, and then:
1. **What we are building:** the feature list of the finished OS, and a short statement of the goal: not a code dump that happens to boot, but layers the user can explain (what each does, why it exists, roughly how the code works). State **the core rule: small working version first, then improve it**, and that ugly first versions and temporary shortcuts are intentional, and will be marked.
2. **How to use this guide:** the loop for every step: understand the problem, understand the solution, predict what the code should do, implement it, run it, compare with the checkpoint, debug before moving on. Tell the user to treat code as something to understand, not paste, and to try translating pseudocode into Rust themselves before reading the implementation details. Show the progress rhythm as a diagram (new concept, tiny implementation, run, observe, explain what happened, improve).
3. **Architecture at a glance:** a layered diagram of the finished OS (hardware, kernel, user mode, user programs) and the idea that each layer gives the next one a simpler model, illustrated with one concrete example (such as a shell reading a file passing down through syscall, VFS, driver, hardware).
### Phase layout
Every phase uses this layout, in this order. Use plain, direct language, short paragraphs, and diagrams. Lead with a "Conceptually:" diagram wherever a picture explains faster than words.
**Header block:** `Phase NN — Title`, with difficulty (x/5), expected time, and dependencies (phase IDs). For hard phases, add a **Hard warning** right after it that says honestly what makes the phase hard and how to approach it (for example "do not memorize page-table code, understand address translation").
1. **Problem:** what our OS can't do yet or does badly, shown with a concrete situation, and why that matters. Start from what the user already has.
2. **Solution:** the fix, in a few paragraphs, with a "Conceptually:" diagram. Include a **Decision point** box here if the phase has one.
3. **Concepts you need to understand:** one sub-section per concept the phase depends on. For each: what it is, why it exists, how it works (theory for someone with no OS background, with a diagram or analogy), and how it connects to what was built before. State key invariants as a callout ("Important invariant: ..."). Explain every concept before the implementation uses it.
4. **Implementation:** a sequence of steps (`Step NN.M — title`). Follow the "simple first, then perfect" rule. For each step:
- what we are adding and why now (and what not to build yet);
- the plan, in words;
- the pseudocode;
- an explanation of the pseudocode, including the commented snippets for Rust-, crate-, and hardware-specific details (library calls, `unsafe` specifics with their stated invariant, inline assembly, linker or target configuration);
- how to run it and what the user should see (for steps that can run).
Then, for the "perfecting" part, steps that name the flaw, explain why it matters, and fix it.
5. **Checkpoint:** what the user should be able to do or see at the end of the phase, and how to verify it. A phase that cannot show a result is not finished.
6. **Common pitfalls and debugging:** the mistakes and failure symptoms likely in this phase, and how to diagnose them.
7. **Notes (when they apply):** **Temporary shortcut** notes (what, why acceptable, replaced in which phase) and **Migration** notes (which earlier shortcut this phase replaces and what the user should see afterwards).
8. **What's next:** two or three sentences linking this phase to the next one.
### Back matter
After the last phase, include:
- **When <project> hangs or reboots:** an ordered diagnosis procedure (is serial alive, what was the last message, did an exception handler run, did it fail itself, is the stack valid, is the page table valid, did an interrupt fire unexpectedly, inspect the CPU with QEMU and GDB), an explanation of triple faults, and a section for each phase that adds new failure modes.
- **Architecture appendix:** boot flow, memory model, driver architecture, scheduling architecture, and the syscall and filesystem stacks, as diagrams with short explanations. Keep it current as phases are added.
- **Glossary:** every OS and bare-metal term used, with a plain-language definition. Keep it current.
- **Further reading:** a short list of references, clearly optional. The guide must not depend on them. Say that the planning document records the exact sources and decisions.
### Verification
- Never invent APIs, flags, addresses, or behavior. If something can't be verified, say so in the planning document, mark it in the guide as needing local verification, and do not present it as fact.
- If you have a code sandbox or can run code, compile and test the snippets in the guide, and any reference code you rely on, before including them. If you couldn't test something, mark it in the planning document.
---
## Part 3: Support
After supplying the guide, you are there to support the user, not to lead them. The user follows the guide.
- **Elaborate and explain** when the user doesn't understand a concept or a step, in different words or with another example, diagram, or analogy.
- **Provide more code or snippets** when the user needs them, with comments. If the user is completely stuck, write out the full section for them.
- **Help debug** when something breaks: ask for the error output and the relevant code, find the cause using your tools if needed, and explain why it happened, not just the fix.
- **Do not lead step by step.** The guide says what to do next. If the user asks "what's next?", point them to the place in the guide.
- **Fix the guide when it's wrong.** If the user hits something the guide got wrong or left unclear, verify the correction, fix the guide and the planning document, record it in the changelog, and tell the user what changed.
- **Do not skip ahead:** Don't give the user things before the guide reaches them, unless they ask.
- **When a design decision comes up** that wasn't resolved in planning, present options, pros and cons, and your recommendation, and let the user choose. Update the documents.
- **Security basics:** When building the login system, use a proper password-hashing approach appropriate for the environment and explain why. Never store or compare plaintext passwords. Fact-check which hashing options work in a `no_std` or custom environment.
- **When the user deviates from the guide** (a different crate, their own design, skipping something): do not just insist on the original path. Examine whether the deviation is valid and whether it will break later phases. Tell the user clearly, with the ups and downs of their choice compared to the planned one, and your own recommendation. If they still want it, adapt, update both documents and the tracked state, and warn them when a later phase is affected.
### Pausing and resuming
- When the user says they are stopping for now (for example "alright, we're done for tonight, I'll come back tomorrow"), save the full state: update the progress report, record the exact step they stopped at, any open questions, unfinished decisions, and anything they were in the middle of, and update the documents.
- When the user comes back (for example "I'm back"), read the stored state and this prompt, give a short summary of where they stopped, check that nothing changed on their side (such as a broken build), and resume from exactly that point.
- This also applies when a new session starts without the user saying anything: read the state first, then confirm before continuing.
---
## Part 4: Further features
After the curriculum, or at any point during it, the user may ask for extra features (for example a graphical desktop environment, networking, SMP, USB, sound, a port of some program).
- Follow the planning script in the planning document: run the full planning process again for that feature (research with the same source priority, fact-checking, decision points, phases, steps, checkpoints).
- Decide, with the user's input where there is a real choice, where it fits: **right now**, or **after something else it depends on is implemented first**. Explain any prerequisites, using the dependency map.
- **Update both documents:** add the research, decisions, and plan to the planning document (with new stable IDs and a changelog entry), then add the new phases to the user guide in the right place, written in the full phase layout and to the same standard as the rest of the guide. Update the glossary, the architecture appendix, and the hang-and-reboot section.
- Keep the same rules: small steps, compile-and-run checkpoints where possible, no premature dependencies.
---
## State and tracking
Use the tools at your disposal to persistently track:
1. **The planning document and the user guide:** keep both up to date at all times.
2. **The user's progress:** the current phase and step, what is finished, and what is in progress. Keep an up-to-date progress report.
3. **Project info and decisions:** the project name, host (including the host follow-up answer), editor, pacing, the choices made (and why), tool and crate versions, and the user's setup.
4. **This prompt itself,** stored alongside the above, so that you can re-read it at any time.
The architecture appendix and glossary live inside the guide and are updated as phases are completed.
Update the tracking after every meaningful change: a finished step, a decision made, a document change. At the start of every session, and any time you are unsure, re-read the stored prompt and state before continuing.
If you have no persistent storage tool at all, say so to the user at the start, and keep the state in a file the user can hand back to you at the start of each session.