קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
אתם יכולים לתת ל-Gemini ב-Android Studio הוראות מותאמות אישית לפעולה באמצעות קובץ אחד או יותר של AGENT.md. קובצי AGENT.md ממוקמים לצד הקבצים האחרים בבסיס הקוד, כך שקל להכניס אותם למערכת בקרת הגרסאות (VCS) ולשתף עם כל הצוות הוראות ספציפיות לפרויקט, כללים לסגנון קידוד והנחיות אחרות.
תחילה, מבצעים את הפעולות הבאות:
יוצרים קובץ AGENT.md בכל מקום במערכת הקבצים של הפרויקט. כששולחים שאילתה, Gemini סורק את הספרייה הנוכחית ואת כל ספריות ההורה כדי למצוא קבצים מסוג AGENT.md. מידע נוסף זמין במאמר איך פועלים קובצי AGENT.md.
מוסיפים את ההוראות. כותבים את ההוראות באמצעות Markdown. כדי שהכללים יהיו קלים לקריאה, כדאי להשתמש בכותרות ובתבליטים.
דוגמאות להוראות
שומרים את הקובץ ומבצעים commit למערכת בקרת הגרסאות כדי לשתף אותו עם הצוות.
ניהול קבצים של AGENT.md כהקשר
אתם יכולים להוסיף או להסיר קבצים כהקשר לשאילתה מסוימת באמצעות מגירת ההקשר בחלונית הצ'אט.AGENT.md האפשרויות AGENT.md קבצים כוללות את כל הקבצים AGENT.md בספרייה הנוכחית ובספריות ההורה שלה.
איור 1. לנהל AGENT.md קבצים כהקשר.
הוראות לדוגמה
אפשר להשתמש בקובץ AGENT.md כדי לתת הוראות לסוכן. ריכזנו כאן כמה דוגמאות, אבל ההוראות שאתם מספקים צריכות להיות ספציפיות לפרויקט שלכם.
"הפעילות העיקרית היא /path/to/MainActivity.kt".
"The code to support navigating between screens is
path/to/navigation/UiNavigation.kt"
"הקוד שמטפל בבקשות HTTP נמצא בכתובת <path>".
ארכיטקטורת הפרויקט
"Place all business logic in ViewModels."
"תמיד צריך לפעול לפי ההמלצות הרשמיות לגבי ארכיטקטורה, כולל שימוש בארכיטקטורה שכבתית. שימוש בזרימת נתונים חד-כיוונית (UDF), ב-ViewModels, באיסוף של מצב ממשק המשתמש שמודע למחזור החיים ובהמלצות אחרות".
הגדרת שמות של placeholder לשירותי API נפוצים או לטרמינולוגיה פנימית:
"שירות ה-backend הראשי נקרא PhotoSift-API".
מדריכי סגנון של חברות: "כל רכיבי ממשק המשתמש החדשים חייבים להיבנות באמצעות Jetpack
Compose. אל תציע פריסות שמבוססות על XML".
חלוקת קובצי AGENT.md למודולים
אפשר לפצל קובצי AGENT.md גדולים לקבצים קטנים יותר שאפשר לעשות בהם שימוש חוזר בהקשרים שונים:
להפריד קבוצת הוראות ולשמור אותן בקובץ Markdown אחר, כמו style-guidance.md.
מפנים לקובצי ה-Markdown הקטנים יותר בקובץ AGENT.md באמצעות הסמל @ ואחריו הנתיב לקובץ שרוצים לייבא. אפשר להשתמש בפורמטים הבאים של נתיבים:
נתיבים יחסיים:
@./file.md – ייבוא מאותה ספרייה
@../file.md – ייבוא מספריית האב
@./subdirectory/file.md – ייבוא מספריית משנה
נתיבים מוחלטים: @/absolute/path/to/file.md
לדוגמה, קובץ AGENT.md הבא מפנה לשני קובצי הוראות אחרים:
# My AGENT.md
You are an experienced Android app developer.
@./get-started.md
## Coding style
@./shared/style-guidance.md
הסבר על קובצי AGENT.md
Gemini סורק באופן אוטומטי את הספרייה הנוכחית ואת ספריות האב כדי למצוא קבצי AGENT.md, ומוסיף את התוכן שלהם לתחילת כל הנחיה בתור מבוא. אם לא פותחים קובץ כששולחים שאילתה, קובץ AGENT.md בשורש הפרויקט (אם יש כזה) נכלל כברירת מחדל.
מה ההבדל בין קובצי AGENT.md לבין כללים?
כללים מאפשרים גם להגדיר הוראות והעדפות שחלות על כל ההנחיות. עם זאת, הכללים מוגדרים בקובץ IntelliJ /.idea/project.prompts.xml, ואילו קובצי AGENT.md נשמרים לצד קוד המקור והם לא תלויים ב-IDE. מומלץ להשתמש בקובצי AGENT.md אם אחת מהמטרות העיקריות היא לשתף את ההוראות עם הצוות.
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. Java ו-OpenJDK הם סימנים מסחריים או סימנים מסחריים רשומים של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-08-22 (שעון UTC).
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["חסרים לי מידע או פרטים","missingTheInformationINeed","thumb-down"],["התוכן מורכב מדי או עם יותר מדי שלבים","tooComplicatedTooManySteps","thumb-down"],["התוכן לא עדכני","outOfDate","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["בעיה בדוגמאות/בקוד","samplesCodeIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 2025-08-22 (שעון UTC)."],[],[],null,["# Customize Gemini using AGENT.md files\n\nGive Gemini in Android Studio customized instructions to follow using one or\nmore `AGENT.md` files. `AGENT.md` files are placed alongside the other files in\nyour codebase, so it's straightforward to check them in to your version control\nsystem (VCS) and share project-specific instructions, coding style rules, and\nother guidance with your entire team.\n\nTo get started, follow these steps:\n\n1. Create an `AGENT.md` file anywhere in your project's file system. Gemini\n scans the current directory and all parent directories for `AGENT.md` files when\n you submit a query. For more details, see [How `AGENT.md` files work](#how-agent-files-work).\n\n | **Tip:** Use multiple instruction files across different directories for more granular control over different parts of your codebase. For example, you can have a global `AGENT.md` file at the project root and more specific `AGENT.md` files in subdirectories for different modules.\n2. Add your instructions. Write your instructions using Markdown. For\n readability, consider using headings and bullet points for different rules.\n [See example instructions](#example-instructions).\n\n3. Save and commit the file to your VCS to share it with your team.\n\nManage `AGENT.md` files as context\n----------------------------------\n\nYou can apply or remove `AGENT.md` files as context for a particular query\nusing the **Context** drawer in the chat panel. The **`AGENT.md` Files** options\nincludes all `AGENT.md` files in the current directory and its parent\ndirectories.\n**Figure 1.** Manage `AGENT.md` files as context.\n\nExample instructions\n--------------------\n\nYou can use the `AGENT.md` file to give instructions to the agent. The following\nare some examples, but the instructions that you provide should be specific to\nyour project.\n\n- \"The main activity is `/path/to/MainActivity.kt`.\"\n- \"The code to support navigating between screens is `path/to/navigation/UiNavigation.kt`\"\n- \"The code handling HTTP requests is at `\u003cpath\u003e`.\"\n- Project architecture\n - \"Place all business logic in ViewModels.\"\n - \"Always follow official architecture recommendations, including use of a layered architecture. Use a unidirectional data flow (UDF), ViewModels, lifecycle-aware UI state collection, and other recommendations.\"\n- Preferred libraries: \"Use the \\\u003clibrary name\\\u003e library for navigation.\"\n- Defining placeholder names for common API services or internal terminology: \"The primary backend service is referred to as 'PhotoSift-API'.\"\n- Company style guides: \"All new UI components must be built with Jetpack Compose. Don't suggest XML-based layouts.\"\n\nModularize your `AGENT.md` files\n--------------------------------\n\nYou can break down large `AGENT.md` files into smaller files that can be reused\nin different contexts:\n\n1. Separate out a set of instructions and save them in another Markdown file,\n such as `style-guidance.md`.\n\n2. Reference the smaller Markdown files in an `AGENT.md` file by using the `@`\n symbol followed by the path to the file you want to import. The following path\n formats are supported:\n\n - Relative paths:\n - `@./file.md` - Import from the same directory\n - `@../file.md` - Import from the parent directory\n - `@./subdirectory/file.md` - Import from a subdirectory\n - Absolute paths: `@/absolute/path/to/file.md`\n\nFor example, the following `AGENT.md` file references two other instruction\nfiles: \n\n # My AGENT.md\n\n You are an experienced Android app developer.\n\n @./get-started.md\n\n ## Coding style\n\n @./shared/style-guidance.md\n\nHow `AGENT.md` files work\n-------------------------\n\nGemini automatically scans the current directory and parent directories for\n`AGENT.md` files and adds their content to the beginning of every prompt as a\npreamble. If you don't have a file open when you submit a query, then the\n`AGENT.md` file at the project root (if there is one) is included by default.\n| **Note:** If you have a `GEMINI.md` file and `AGENT.md` file in the same directory, the `GEMINI.md` file takes precedence.\n\nWhat's the difference between `AGENT.md` files and Rules?\n---------------------------------------------------------\n\n[Rules](/studio/gemini/rules) also let you define instructions and preferences\nthat apply to all prompts. However, rules are defined in the IntelliJ file\n`/.idea/project.prompts.xml`, whereas `AGENT.md` files are saved next to your\nsource code and are IDE-neutral. We recommend using `AGENT.md` files if one of\nthe primary purposes is to share the instructions with your team.\n| **Note:** Gemini combines rules and instructions in `AGENT.md` files when processing your query."]]