> For the complete documentation index, see [llms.txt](https://code.national-cat.me/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://code.national-cat.me/readme.md).

# 前言

要改善程式碼不會是一兩天的事情，除了長期規劃外，還需要不斷地寫測試與重構。

這是我累積了多年來的 Clean Code 技巧，過去藉由不公開經驗來讓公司在市場上達到技術上的優勢，也確實達到了。

開發五年的系統，擁有上千支 API 的開發日常：

* 從拿到金流開發文件到正式機上線，只花費不到兩週
* 開發新功能是以小時為單位來估時間，幾乎沒有功能需要開發超過一個月
* 大家可以專心在商業邏輯上，而不是花時間在反覆閱讀程式碼

***

這些筆記主要以 PHP + Laravel 來舉例。所有篇章閱讀沒順序，可以跳著讀。

GitBook 的編輯記錄：<https://github.com/Nationalcat/code.national-cat.me>

***

<figure><img src="https://1639117993-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3VRlg4535ocvLqJ46mOo%2Fuploads%2Fgit-blob-b9a55533c0cb035de1769b2a5ac63ce9b194fc69%2Fby-nc-sa.png?alt=media" alt="" width="202"><figcaption><p><a href="https://code.national-cat.me/">clean code </a>© 2023 by <a href="https://github.com/Nationalcat">National-cat </a>is licensed under <a href="http://creativecommons.org/licenses/by-nc-sa/4.0/?ref=chooser-v1">CC BY-NC-SA 4.0 </a></p></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://code.national-cat.me/readme.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
