Prompt站外收录 @promptlib/text-2122228185297907713
Copilot 上下文工程指南
帮助开发者优化项目结构和代码风格,提升 GitHub Copilot 的理解力与建议质量。
提示词
# Context Engineering
Principles for helping GitHub Copilot understand your codebase and provide better suggestions.
## Project Structure
- **Use descriptive file paths**: `src/auth/middleware.ts` > `src/utils/m.ts`. Copilot uses paths to infer intent.
- **Colocate related code**: Keep components, tests, types, and hooks together. One search pattern should find everything related.
- **Export public APIs from index files**: What's exported is the contract; what's not is internal. This helps Copilot understand boundaries.
## Code Patterns
- **Prefer explicit types over inference**: Type annotations are context. `function getUser(id: string): Promise<User>` tells Copilot more than `function getUser(id)`.
- **Use semantic names**: `activeAdultUsers` > `x`. Self-documenting code is AI-readable code.
- **Define constants**: `MAX_RETRY_ATTEMPTS = 3` > magic number `3`. Named values carry meaning.
## Working with Copilot
- **Keep relevant files open in tabs**: Copilot uses open tabs as context signals. Working on auth? Open auth-related files.
- **Position cursor intentionally**: Copilot prioritizes code near your cursor. Put cursor where context matters.
- **Use Copilot Chat for complex tasks**: Inline completions have minimal context. Chat mode sees more files.
## Context Hints
- **Add a COPILOT.md file**: Document architecture decisions, patterns, and conventions Copilot should follow.
- **Use strategic comments**: At the top of complex modules, briefly describe the flow or purpose.
- **Reference patterns explicitly**: "Follow the same pattern as `src/api/users.ts`" gives Copilot a concrete example.
## Multi-File Changes
- **Describe scope first**: Tell Copilot all files involved before asking for changes. "I need to update the User model, API endpoint, and tests."
- **Work incrementally**: One file at a time, verifying each change. Don't ask for everything at once.
- **Check understanding**: Ask "What files would you need to see?" before complex refactors.
## When Copilot Struggles
- **Missing context**: Open the relevant files in tabs, or explicitly paste code snippets.
- **Stale suggestions**: Copilot may not see recent changes. Re-open files or restart the session.
- **Generic answers**: Be more specific. Add constraints, mention frameworks, reference existing code.
变量使用 {{name}} 声明,复制时保留占位符
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
吉伊卡哇风格科普插画
吉伊卡哇(ちいかわ)官方漫画风格科普插画,画面比例 [ASPECT_RATIO],讲解 [TOPIC]。 === 标题 === 主标题“[MAIN_TITLE
站外吉伊卡哇漫画
1.8w 0.0
蜡笔小新搞怪涂鸦风格科普插画
蜡笔小新(臼井仪人)动画风格科普插画,画面比例 [ASPECT_RATIO],讲解 [TOPIC]。 === 标题 === “[MAIN_TITLE]”使用活
站外蜡笔小新扁平化
1w 0.0
美式超级英雄漫画
生成现代美式超级英雄图像小说风格漫画,画面比例 [ASPECT_RATIO],共 [NUMBER] 格,讲解 [TOPIC]。 === 标题 === “[MA
站外美式漫画超级英雄
1.6k 0.0
美式波普漫画风小红书插图
小红书风格的高活力波普漫画插画,画面比例 [ASPECT_RATIO],制作关于 [TOPIC] 的知识型封面。 === 标题设计 === 主标题“[MAIN
站外波普风美式漫画
1.4k 0.0
举报「Copilot 上下文工程指南」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次