How to create Agent Skills for Gemini CLI

1. Introduction

In this lab, you will learn how to create Agent Skills to provide LLMs with access to bespoke knowledge and workflows. You will create it as a local skill that can be accessed from Gemini CLI.

What you'll do

  • Create your own Agent Skills for your favorite things.
  • Use Gemini CLI to query your skill.
  • Install official Agent Skills for Firebase and use them to build and deploy an app.

What you'll learn

  • How to structure a skill.
  • How to write a SKILL.md file.
  • How to use local skills with Gemini CLI.

2. Project Setup

  1. If you don't already have a Google Account, you must create a Google Account.
    • Use a personal account instead of a work or school account. Work and school accounts may have restrictions that prevent you from enabling the APIs needed for this lab.
  2. Sign-in to the Google Cloud Console.
  3. Enable billing in the Cloud Console.
    • Completing this lab should cost less than $1 USD in Cloud resources.
    • You can follow the steps at the end of this lab to delete resources to avoid further charges.
    • New users are eligible for the $300 USD Free Trial.
  4. Create a new project or choose to reuse an existing project.
    • If you see an error about project quota, reuse an existing project or delete an existing project to create a new project.

3. Open Cloud Shell Editor

  1. Click this link to navigate directly to Cloud Shell Editor
  2. If prompted to authorize at any point today, click Authorize to continue. Click to authorize Cloud Shell
  3. If the terminal doesn't appear at the bottom of the screen, open it:
    • Click View
    • Click TerminalOpen new terminal in Cloud Shell Editor
  4. In the terminal, set your project with this command:
    • Format:
      gcloud config set project [PROJECT_ID]
      
    • Example:
      gcloud config set project lab-project-id-example
      
    • If you can't remember your project id:
      • You can list all your project ids with:
        gcloud projects list | awk '/PROJECT_ID/{print $2}'
        
      Set project id in Cloud Shell Editor terminal
  5. You should see this message:
    Updated property [core/project].
    
    If you see a WARNING and are asked Do you want to continue (Y/n)?, then you have likely entered the project ID incorrectly. Press n, press Enter, and try to run the gcloud config set project command again.

4. Create your "favorite things" skill

Agent Skills are directories containing at minimum a SKILL.md file that provides instructions and knowledge to an AI agent. In this section, you will create a skill that teaches Gemini CLI about your favorite things.

  1. Create a directory to store your skill:
    mkdir -p ~/.gemini/skills/my-favorite-things
    
  2. Create and open a new SKILL.md file for your skill:
    cloudshell edit ~/.gemini/skills/my-favorite-things/SKILL.md
    
    The cloudshell edit command will open the SKILL.md file in the editor above the terminal.
  3. Add the following content to the SKILL.md file:
    ---
    name: my-favorite-things
    description: Information about my favorite things. Use this skill to answer questions about my favorite color, food, or programming language.
    ---
    
    My favorite color is blue.
    My favorite food is pizza.
    My favorite programming language is Python.
    
    If asked about one of my favorite things, please respond with the information provided above.
    

With only a SKILL.md file, you have created your first skill! It is time to use this skill in Gemini CLI.

5. Use your skill from Gemini CLI

Now that you've successfully created a skill, you can use it with Gemini CLI. Skills placed in ~/.gemini/skills are automatically discovered by Gemini CLI.

  1. Start the Gemini CLI in Cloud Shell
    gemini
    
    You may need to press Enter to accept some default settings.
  2. Have gemini list the skills available to it within its context
    /skills
    
    You should see my-favorite-things in the list of available skills.
  3. Ask gemini about your favorite color:
    What is my favorite color?
    
    The Gemini CLI should use the my-favorite-things skill to answer your question. If prompted, allow Gemini CLI to use the skill.

The output should show that Gemini CLI used your skill and replied with "Blue.".

You have done it! You have successfully created a skill and tested it using Gemini CLI.

When you are ready to end your session, type /quit and then press Enter to exit Gemini CLI.

6. Install Agent Skills for Firebase

In addition to creating your own skills, you can install skills created by others. Agent Skills for Firebase (GitHub) are portable, self-contained modules of Firebase-specific knowledge, instructions, and workflows. They're designed to help AI assistants understand Firebase best practices and execute complex tasks with higher accuracy and lower token cost.

You can install all Agent Skills for Firebase with with the skills CLI in your terminal:

npx skills add firebase/agent-skills

This command will download and install skills including firebase-basics, firebase-auth-basics, firebase-firestore-basics, and firebase-app-hosting-basics, making them available for use in Gemini CLI alongside your my-favorite-things skill.

To learn more about Agent Skills for Firebase, see Available skills.

7. Explore the Agent Skills for Firebase

The Agent Skills for Firebase are now installed and ready to use in Gemini CLI. You can see them by running Gemini CLI and typing /skills firebase:

gemini

Then in Gemini CLI:

/skills firebase

You will see a list of installed Firebase skills, like firebase-basics, firebase-auth-basics, firebase-firestore-basics, and firebase-app-hosting-basics.

8. (Optional) Use Agent Skills for Firebase to create and deploy an application

Now use the installed Agent Skills for Firebase to create a "To Do" web application, with user authentication and a database, and deploy it to Firebase App Hosting.

  1. If you are still in Gemini CLI, type /quit to exit.
  2. Create a new directory for your project and navigate into it:
    mkdir todo-app && cd todo-app
    
  3. Log in to Firebase using your Google account. If you are in Cloud Shell or another environment without a browser, use the --no-localhost flag.
    firebase login --no-localhost
    
    Follow the instructions to authorize Firebase CLI.
  4. Start Gemini CLI:
    gemini
    
  5. Now, ask Gemini to generate the application code:
    Generate HTML, CSS, and Javascript for a single page  application. It should use Google Sign-in with Firebase Authentication, and save tasks in Cloud Firestore for the signed-in user. A user should be able to add new tasks and see a list of their tasks.
    
    Gemini may ask to create files like index.html, style.css, and script.js. Allow it to do so.
  6. Finally, deploy the application to Firebase App Hosting:
    /firebase-app-hosting-basics deploy my web app to Firebase App Hosting.
    
    Follow any prompts to configure App Hosting and complete the deployment. Once deployed, you should receive a URL for your live application!

9. Conclusion

Congratulations! You have successfully created a skill and learned how to install additional skills for Gemini CLI.

(Optional) Clean up

If you would like to clean up, you can delete your Cloud project to avoid incurring additional charges.

If you would like, delete the project:

gcloud projects delete $GOOGLE_CLOUD_PROJECT

You may also want to delete unnecessary resources from your cloudshell disk. You can:

  1. Delete the skill directory:
    rm -rf ~/.gemini/skills/my-favorite-things
    
  2. Warning! This next action is can't be undone! If you would like to delete everything on your Cloud Shell to free up space, you can delete your whole home directory. Be careful that everything you want to keep is saved somewhere else.
    sudo rm -rf $HOME