「Write a main function where a connection to
DATABASE is created. 包括健康檢查。」
「請以以下結構撰寫 FUNCTION_OR_CLASS:
EXPLAIN_STRUCTURE。」
產生程式碼後,請嘗試使用後續提示詞來改善程式碼:
「請嘗試使用 /fix 指令調整產生的程式碼,例如語法錯誤。」
「Add missing imports.」(新增缺少的匯入項目)。
「Try /fix on chat-generated code.」
清理、簡化及重構程式碼
在 Gemini Code Assist 對話中嘗試使用下列提示:
「Can you merge
IMPORTS_VARIABLES_OR_NOTE_EXPORTED_FUNCTIONS
in this file?」(可以合併這個檔案中的內容嗎?)
「你會如何簡化
FUNCTION_NAME函式?」
「Can you merge FUNCTION_NAME_1 and
FUNCTION_NAME_2 into one function?」
「Could you inline some variables in
FUNCTION_NAME?」
「Could you simplify variable naming in the function
FUNCTION_NAME?」(請簡化函式 FUNCTION_NAME 中的變數命名)。
可讀性
在 Gemini Code Assist 對話中嘗試使用下列提示:
「請盡可能以較少的程式碼行數編寫 FUNCTION_NAME 函式。」
「Add comments to the function
FUNCTION_NAME.」
「Remove unnecessary whitespaces in the function
FUNCTION_NAME.」
「Format the function FUNCTION_NAME in a
similar way as the rest of the code.」
審查程式碼
在 Gemini Code Assist 對話中嘗試使用下列提示:
「將程式碼分成幾個部分,並使用我們的程式碼庫說明每個部分。」
「是否有更簡短且更容易瞭解的變數或關鍵字?」
「Can you give me useful code from the
REPOSITORY_NAME_PACKAGE_MODULE context for
this code?」
「你對函式 FUNCTION_NAME 有什麼看法?」
偵錯
在 Gemini Code Assist 對話中嘗試使用下列提示:
「我在嘗試執行 X/新增 Y 時收到錯誤訊息。為什麼?」
「Can you spot an error in the function
FUNCTION_NAME?」
「如果出現這個錯誤訊息,你會如何修正函式?
FUNCTION_NAME」
學習與新手上路
在 Gemini Code Assist 對話中嘗試使用下列提示:
「將這段程式碼分成幾個部分,並使用我們的程式碼集說明每個部分。」
「Show how to call function
FUNCTION_NAME?」
「Show how to run the main function in the
ENVIRONMENT_NAME environment?」
「我們可以進行哪些重大技術改良,讓這段程式碼的效能更高?」
「Show me the implementation of
FUNCTION_OR_CLASS_NAME to achieve better
results and add what that specific element is」(顯示 FUNCTION_OR_CLASS_NAME 的實作方式,以獲得更佳結果,並新增該特定元素) - 例如「Show me the implementation of function foo where foo is the name of
the function」(顯示函式 foo 的實作方式,其中 foo 是函式的名稱)。
遷移
在 Gemini Code Assist 對話中嘗試使用下列提示:
「請提供從 LANGUAGE_1 遷移至 LANGUAGE_2 的策略,例如從 Go 遷移至 Python。」FILE_NAME