The GitHub Blog 10月01日
用Markdown编写AI辅助开发,提升效率
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

本文介绍了一种创新的AI辅助开发工作流,核心是将应用程序的全部代码和设计决策写入Markdown文件,然后利用AI编码助手(如GitHub Copilot)将其转换为实际代码。这种方法通过将用户文档(README.md)和AI规范(main.md)整合,确保了文档与代码的同步性。开发者只需编辑Markdown文件,AI即可生成Go代码,大大简化了开发流程,尤其适用于快速迭代和原型设计。文章还探讨了如何通过专门的提示文件(compile.prompt.md, lint.prompt.md)来指导AI进行代码生成和优化,并分享了实践中的观察和未来可能的发展方向,如模块化代码和集成测试。

✍️ **Markdown作为核心开发语言**:文章提出将应用程序的所有逻辑和设计细节写在Markdown文件中,AI编码助手(如GitHub Copilot)负责将其转换为实际的编程语言(例如Go)。这种方式将人机交互的重点从直接编写代码转移到清晰地描述需求和设计,从而简化了开发过程。

📄 **文档与代码的同步**:通过将用户文档(README.md)的内容嵌入到AI规范文件(main.md)中,可以确保在更新代码逻辑时,相关的用户说明也能同步更新,避免了信息脱节,使得文档始终与应用的实际功能保持一致。

🚀 **简化的开发与迭代流程**:开发者只需编辑Markdown文件,然后通过一个简单的编译提示文件(compile.prompt.md)指示AI生成代码。每次修改后,只需重新运行AI即可生成更新后的代码,大大缩短了开发周期,特别适合快速原型开发和功能迭代。

🧹 **AI驱动的代码优化与审查**:利用专门的提示文件(如lint.prompt.md),可以指导AI对Markdown规范进行优化,使其更清晰、简洁,减少歧义。AI不仅能生成代码,还能帮助审查和优化描述代码的文本本身,实现更高效的开发和代码质量管理。

💡 **未来展望与挑战**:文章也指出了该方法在编译速度和测试集成方面可能面临的挑战,并提出了未来可以探索的方向,如将编译后的代码分解为多个模块,以及更深入地集成自动化测试,以应对大型项目的需求。

The usual workflow with AI coding agents like GitHub Copilot is simple: “Write app A that does X. You start with that seed, then iterate: “Add feature Y,” “Fix bug Z. This works, at least until the agent loses track of your app’s purpose or past decisions. 

If you’re new to AI coding agents, the change is subtle. Suddenly, the agent asks you to repeat things you’ve already explained, or suggests changes that ignore your previous instructions. Sometimes, it forgets why a feature exists, or proposes solutions that contradict earlier choices.

Some AI coding agents try to address this by supporting custom instructions files. For example, GitHub Copilot supports copilot-instructions.md. You can put your app’s purpose and design decisions in this Markdown file, and GitHub Copilot will read it every time it generates code.

When I’m in a coding rush, I often forget to update copilot-instructions.md after asking GitHub Copilot to do things. It feels redundant to put the same information into both the chat prompt and the instructions file.

Try Spec Kit: Spec-driven development made practical

Spec Kit provides a structured process to bring spec-driven development to your coding agent workflows with tools including GitHub Copilot, Claude Code, and Gemini CLI. Plus, it’s open source (and we’re updating it constantly). 

👉 Get started with Spec Kit on GitHub

Which made me wonder: What if I “wrote” the entire app in the Markdown instructions file?

For my latest pet project — GitHub Brain MCP Server — I tried exactly that by writing the app code in Markdown and letting GitHub Copilot compile it into actual Go code. As a result, I rarely edit or view the app’s Go code directly. 

This process should work with any AI coding agent and programming language, though I’ll use VS Code, GitHub Copilot, and Go as examples. GitHub Brain MCP Server will be my example app throughout this post.

Let’s jump in. 

Setup: What I used to get started

There are four key files:

.├── .github/│   └── prompts/│       └── compile.prompt.md├── main.go├── main.md└── README.md

At a high level, I edit README.md or main.md to develop the app, invoke compile.prompt.md to let the AI coding agent generate main.go, then build and run main.go like any other Go app. Next, I’ll break down each file and the workflow.

README.md: User-facing documentation

The example app, GitHub Brain MCP Server, is a command-line tool. Its README.md provides clear, user-facing instructions for installation and usage. If you write libraries, this file should contain API documentation. Below is a condensed excerpt from the example app’s README.md:

# GitHub Brain MCP Server**GitHub Brain** is an experimental MCP server for summarizing GitHub discussions, issues, and pull requests.## Usage```shgo run main.go <command> [<args>]```**Workflow:**1. Populate the local database with the `pull` command.2. Start the MCP server with the `mcp` command.### `pull`Populate the local database with GitHub data.Example:```shgo run main.go pull -o my-org```Arguments:- `-t`: Your GitHub personal access token. **Required.**- `-o`: The GitHub organization to pull data from. **Required.**- `-db`: Path to the SQLite database directory. Default: `db` folder in the current directory.### `mcp`Start the MCP server using the local database....README.md continues...

Nothing special here ,  just regular documentation. But it gets interesting when this file is included in main.md.

main.md: AI coding agent specification

main.md is the actual source code of the app: the Markdown instructions file. Whenever I need to add features or fix bugs, I edit this file. Here’s the opening of the example app’s main.md:

# GitHub Brain MCP ServerAI coding agent specification. User-facing documentation in [README.md](README.md).## CLIImplement CLI from [Usage](README.md#usage) section. Follow exact argument/variable names. Support only `pull` and `mcp` commands.## pull- Resolve CLI arguments and environment variables into `Config` struct:  - `Organization`: Organization name (required)  - `GithubToken`: GitHub API token (required)  - `DBDir`: SQLite database path (default: `./db`)- Use `Config` struct consistently, avoid multiple environment variable reads- Pull items: Repositories, Discussions, Issues, Pull Requests, Teams- Use `log/slog` custom logger for last 5 log messages with timestamps in console output...main.md continues...

Notice how the user-facing documentation from README.md is embedded in the specification. This keeps documentation and implementation in sync. If I want to add an alias for the -o argument, I just update README.md with no extra steps required.

Here’s another snippet from the example app’s main.md:

### Discussions- Query discussions for each repository with `has_discussions_enabled: true`- Record most recent repository discussion `updated_at` timestamp from database before pulling first page```graphql{  repository(owner: "<organization>", name: "<repository>") {    discussions(first: 100, orderBy: { field: UPDATED_AT, direction: DESC }) {      nodes {        url        title        body        createdAt        updatedAt        author {          login        }      }    }  }}```- If repository doesn't exist, remove the repository, and all associated items from the database and continue- Query discussions ordered by most recent `updatedAt`- Stop pulling when hitting discussions with `updatedAt` older than recorded timestamp- Save or update by primary key `url`- Preserve the discussion markdown body...main.md continues...

This is effectively programming in Markdown and plain English: storing variables, loops, and logical conditions. You get all the usual keywords — if, foreach, or continue. It’s a blend of structural and declarative styles, with Markdown links []() for imports.

The database schema is also coded in Markdown:

## DatabaseSQLite database in `{Config.DbDir}/{Config.Organization}.db` (create folder if needed). Avoid transactions. Save each GraphQL item immediately.### Tables#### table:repositories- Primary key: `name`- Index: `updated_at`- `name`: Repository name (e.g., `repo`), without organization prefix- `has_discussions_enabled`: Boolean indicating if the repository has discussions feature enabled- `has_issues_enabled`: Boolean indicating if the repository has issues feature enabled- `updated_at`: Last update timestamp...main.md continues...

compile.prompt.md: AI coding agent prompt

compile.prompt.md uses GitHub Copilot’s prompt file format. This repeatable prompt tells the agent to compile main.md into main.go. Here’s compile.prompt.md from the example app:

---mode: agent---- Update the app to follow [the specification](../../main.md)- Build the code with the VS Code tasks. Avoid asking me to run `go build` or `go test` commands manually.- Fetch the GitHub home page for each used library to get a documentation and examples.

I keep this prompt simple .  The real information is in main.md, after all. This example uses GitHub Copilot’s format, but keeping it simple makes it portable to other AI coding agents.

The workflow to bring this all together

The development loop is straightforward:

    Edit the specification in main.md or README.md.Ask the AI coding agent to compile it into Go code.Run and test the app. Update the spec if something doesn’t work as expected.Repeat.

In GitHub Copilot for VS Code, use the / command to invoke the prompt.

For smaller specs, GitHub Copilot usually catches changes automatically. As the spec grows, I nudge it in the right direction by appending ”focus on <the-change>”.

Coding

Coding in main.md is sometimes harder than writing Go directly . You have to clearly describe what you want, which might be the hardest part of software development 😅. Fortunately, you can use GitHub Copilot to help with this, just like you probably do with your Go code daily.

Here we ask it to add pagination to all MCP tools in main.md. Copilot not only saves us from doing repetitive work, but it also recommends proper pagination style and parameter names.

Linting

main.md can get messy like any code. To help with this, you can ask Copilot to clean it up. Here’s lint.prompt.md from the example app:

---mode: agent---- Optimize [the app specification](../../main.md) for clarity and conciseness- Treat the english language as a programming language- Minimize the number of synonyms - i.e. pull/get/fetch. Stick to one term.- Remove duplicate content- Preserve all important details- Do not modify the Go code with this. Only optimize the Markdown file.- Do not modify this prompt itself.

Like with compile.prompt.md, I use the / command to invoke this prompt. The AI coding agent lints main.md, and if the result looks good, I can compile it to Go with compile.prompt.md.

Closing thoughts

After a few months using this workflow, here are my observations:

Something else I want to try next? Discarding all Go code and regenerating the app from scratch in another language. Will the new code work right away?

The rapid advances in this field are really encouraging, and I hope my experimental workflows give you some practical ideas to try. 

The post Spec-driven development: Using Markdown as a programming language when building with AI appeared first on The GitHub Blog.

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

AI开发 Markdown GitHub Copilot Spec-driven Development 编程效率 AI-assisted Development Markdown Programming GitHub Copilot Workflow Code Generation
相关文章