# AI 可读命名规则

{% hint style="info" %}
此文档仍在审核中。我们希望通过[GitHub 的 Issue](https://github.com/AI-Native-Development/patterns/issues/6)积极讨论。
{% endhint %}

## 描述

本文介绍了有助于编写 AI 代码和使用 AI 代码支持工具的命名规则模式。通过使用这些模式，可以编写更易于阅读和理解的代码。

## 问题

在编写代码时，人们经常会感到犹豫变量或函数的命名。此外，仅通过注释来提供上下文，代码往往难以理解。这种难以阅读的代码也会影响 GitHub Copilot 的准确性，最终导致无法从 GitHub Copilot 获取准确的建议。

## 背景

AI 代码支持工具 GitHub Copilot 使用了名为 Codex 的引擎，该引擎使用基于 GPT3 的模型。基于 GPT3 的模型可以理解自然语言，Codex 也可以理解自然语言。通过使用类似自然语言的变量表示，可以编写更易于阅读和理解的代码。

## 解决方案

在编写代码时，如果您对变量或函数名称感到困惑，请首先创建一个团队共同遵循的命名规则，以便 AI 代码支持工具可以阅读。通过类似自然语言的变量表示，而不是仅通过注释提供上下文，AI 代码支持工具可以提供更准确的建议。

以下是命名规则模式的示例。

* 使用小写或驼峰命名法
* 使用类似自然语言的变量表示
* 使用简短的名称
* 使用描述性的名称

## 结果

通过使用这些命名规则模式，可以编写更易于阅读和理解的代码，并使 AI 代码支持工具能够提供更准确的代码建议。


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ai-native-development.gitbook.io/archived/chinese/mo-shi/ai-friendly-naming-convention.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
