Manage knowledge like code: write in Markdown, isolate changes in branches, review through pull requests, and preserve history with Git.
Docs-as-code is a documentation workflow for individuals and teams. It works for research, software, product design, study notes, operations manuals, and any knowledge base that must stay current.
Write first → change on a branch → discuss and review in a PR → merge the current version → keep history in Git
Docs-as-code is more than replacing Word with Markdown. The important part is giving documentation the same lifecycle as code:
- Store documents in a Git repository;
- Do not silently overwrite the current version with important changes;
- Use Pull Requests to show diffs and discuss changes line by line;
- Link decisions, tasks, discussions, and final documents;
- Keep old decisions as history instead of deleting them.
| Situation | Use | Why |
|---|---|---|
| Explain what a project is and how to start | README.md |
Project landing page |
| Record current status and next steps | STATUS.md |
One current status page |
| Track work with an owner or completion criteria | Issue | Actionable work that can be closed |
| Explore an open-ended question | Discussion | Exchange ideas before committing |
| Add or change a document | Branch + Pull Request | Isolate, compare, and review changes |
| Record an important long-lived decision | RFC / ADR / RFD | Preserve rationale and history |
| See many tasks at once | Project | Organize Issues and PRs on a board |
Simple rule: a discussion is not a task, a task is not a durable conclusion, and a conclusion should not live only in comments. Give each object one job, then connect them with links.
For a new guide, revised plan, updated protocol, or correction:
- Create a short-lived branch from
main, such asdocs/update-workflow; - Create or edit the Markdown file on that branch;
- Commit with a message that explains the change;
- Open a Pull Request describing purpose, impact, and open questions;
- Discuss the diff line by line in Files changed;
- Merge into
mainonce review is complete; - Delete the merged branch.
Edit a file or choose Add file
→ Create a new branch for this commit
→ Propose changes
→ Create pull request
→ Review changes
→ Ready for review (if Draft)
→ Merge pull request
→ Delete branch
Tiny typo and link fixes may go directly to main. Changes to meaning, process, interfaces, or conclusions should use a pull request.
A meeting note records what was discussed. An Issue drives the work. A final document preserves the reusable conclusion.
Meeting note
→ Extract an actionable ToDo
→ Create an Issue
→ Research, design, or implement
→ Write the result on a branch
→ Review and merge the PR
→ Link the result in the Issue and close it
→ Check off the ToDo in the meeting note
A useful Issue contains context, the question or action, definition of done, an owner when needed, and links to documents, PRs, and evidence. Do not create an Issue for every five-minute task.
Use GitHub Discussions while the question is still open. Once a concrete option emerges, write a numbered proposal. Choose one convention—RFC, ADR, or RFD—instead of using all three.
Discussion → candidate options → RFD-0001 → PR discussion
→ Accepted / Rejected → link Issues and PRs
→ mark Superseded if a later decision replaces it
Suggested filenames and statuses:
rfds/0001-use-docs-as-code.md
rfds/0002-adopt-a-static-site.md
draft: still being written;discussion: collecting feedback;accepted: adopted;rejected: explicitly not adopted;superseded: replaced by a later decision.
Never delete an accepted or superseded decision merely because it is no longer current. Update its status and link to the replacement.
Before building a substantial feature, experiment, or project, write its README, proposal, or interface first:
- What is the goal?
- Who will use it?
- What are the inputs and outputs?
- What counts as complete?
- What are the constraints and risks?
Agree on the problem through documentation before investing in implementation. Documentation is a design tool, not cleanup work.
- Small fixes may go directly to
main; - Use PRs for important decisions as a self-review through the diff;
- Use Issues to keep tasks out of notes;
- Use RFDs to preserve why a decision was made.
- Everyone starts meaningful work on a branch;
- Important changes receive at least one non-author review;
- Discuss exact wording in PRs and open questions in Discussions;
- Use
CODEOWNERSto assign maintainers to critical paths; - Use GitHub Projects to show overall task status.
README.md
README.zh-CN.md
STATUS.md
meetings/
notes/
rfds/
Add templates, validation scripts, and a static site only when they are needed:
.github/
ISSUE_TEMPLATE/
PULL_REQUEST_TEMPLATE.md
CODEOWNERS
templates/
scripts/
docs/
- One fact has one source of truth. Other places contain summaries and links.
- Use PRs for meaningful changes. A PR is a discussion space, not merely a merge button.
- Issues must be closable. Open-ended questions belong in Discussions.
- Move conclusions into documents. Do not leave final answers only in chats or comments.
- Do not delete old decisions. Mark them
supersededand link the replacement. - Separate evidence from interpretation. Link documents to data, code, logs, or sources.
- Process serves clarity. Keep small changes light and review important changes more carefully.
- Create a repository and
README.md; - State the repository's purpose, audience, and boundaries;
- Create a first meeting note or working note;
- Turn one actionable item into an Issue;
- Change a document on a branch and open a PR;
- Review, merge, and delete the branch;
- Link the result in the Issue and close the task.
- Meeting note, Issue, PR, and RFD templates;
CODEOWNERSexample;- GitHub Projects example;
- Markdown link and metadata checks;
- MkDocs / Docusaurus static-site example;
- Complete individual and team examples.
Contributions and refinements should follow the same workflow described here: branch, pull request, review, and merge.