
When it comes to artificial intelligence, opinions are sharply divided. Some believe AI is an all-powerful entity destined to replace human endeavors, while others view it as a non-judgmental work partner. Given the constantly evolving nature of AI, I currently align with the latter perspective.
As an advocate for AI as a work companion, and given my frequent reliance on Gemini for everything from specialized domain knowledge to decoding my teenager’s perpetual grumpiness, I was eager to explore the new Gemini CLI and custom commands feature.
This article details the process of using the Gemini CLI custom command, an editor designed to analyze blogs and articles against the Google Developer documentation style guide. For this exercise, I have created an abstracted version of Google Developer documentation style guide.
The steps include:
- Using Gemini Canvas mode to analyze the Google documentation style guide
- Abstracting key rules for each sub-heading using Google Sheets and the AI function
- Installing Gemini CLI
- Creating a custom command `.toml` file with the abstracted information
- Validating a poorly formatted file using this custom command
Let’s get started!
You can find the source code for this tutorial https://github.com/shweta345/google-style-editor repository.
As a first step, we will use Gemini in Canvas mode to get URLs for each style rule under https://developers.google.com/style.
- In Gemini, click Canvas mode, and run the following prompt:
Create a google sheet with complete URL link under https://developers.google.com/style.
2. Click the Share icon and click copy contents. We will copy this table to Google sheets for further analysis.
Now that we have each URL in a handy format, we can move towards extracting information for contents on each page. To do that, we will be using the very awesome AI function from Google Sheets.
- Open a new sheet in Google Sheets.
- Copy the contents from the Gemini Canvas to the sheets.
- Create a new column Summarization. This is the column where we will use the AI function to summarize the content.
- In a cell in the Summarization column, enter an AI function, for example in our case `=AI(“Summarize each URL and identify key rules important on that page. List down the rules since these rules will be used with the Gemini CLI”,
)`. The is C2 in case of this example. - Select the cell or cells with an AI function.
- Click Generate and Insert.
- Optional: To refresh output, click Refresh and Insert.
- Repeat step 3 for all rows in the sheet.
The Summarization column now contains abstracted content from the style guide. This summarized information will serve as the rules for the prompt included in the Gemini CLI’s custom command.
Since using the entire style guide might not apply to everyone, you can copy over this abstraction and remove sections that might not apply to you. In our case, we used Gemini to format the content to comply with the `.toml` specification.
From the abstracted content we derived using Google Sheets, we will create the tech-edit.toml file. For ease of use, I have condensed applicable style and formatting rules to a simpler format. You can update it as required.
You can use the tech-edit.toml file or use Gemini to refine the Summarization column output tailored to your requirements.
# ~/.gemini/commands/tech-edit.tomldescription = "Performs technical review based on rules defined in this tool."
prompt = """
You are a senior technical editor with expertise in clear communication, code syntax, and technical accuracy. Your task is to act as a final
reviewer for the article: {{args}}
## Instructions
1. For each section under the “Editing Rules” section, review the article and identify violations. List each violation as a bulleted list.
2. **Factual & Technical Check:** Review and list every factual or technical error you found. For each item, provide the incorrect text, a brief explanation of why it's wrong, and the correct information.
3. **Provide a Detailed Report:** Your final output MUST be a structured report that lists all violations you identified in step 2. Do not include any other conversational text or commentary.
4. Provide the complete, revised article content in a markdown code block. The revised article should incorporate all the corrections from the
previous steps.
### Factual & Technical Inaccuracies
List every factual or technical error you found. For each item, provide the incorrect text, a brief explanation of why it's wrong, and the correct
information.
### Style & Grammar Issues
Based on the rules provided in the sections after the "Instructions" section, list every violation you found. For each item, provide the original text and the
revised text that follows the rule in a tabular format.
### Proposed Revisions
Provide the complete, revised article content in a markdown code block. The revised article should incorporate all the corrections from the
previous two sections.
---
## Editing Rules
....
"""
Gemini CLI is a powerful tool that will help us take these rules and create an editorial tool.
- Make sure that Node.js version 18 is downloaded and installed.
- Run the following command to install the Gemini CLI:
npm install -g @google/gemini-cli
3. Verify that the Gemini CLI is installed.
gemini -v
4. Run the following command to start the Gemini interface
gemini
The first time that you start Gemini CLI, you will be asked to select an authentication method. For simplicity, you can login using your Google account. Once the login completes, you see the following screen that confirms you are ready to use Gemini CLI.
If you want to learn how powerful Gemini CLI is, take a look at this deep dive on the Gemini CLI.
Now that we have Gemini CLI and our abstracted summary of the Google developer style guide ready, we can start creating a custom command that creates a tool that you can call from the CLI and pass your file as input.
Gemini CLI lets you create custom commands through customized `.toml` files. In our example, we will store our custom command `.toml` file in the `~/.gemini/commands/` directory. For a complete deep dive into custom commands, take a look at Gemini CLI: Custom slash commands.
- Create the `commands` directory if it doesn’t already exist.
mkdir -p ~/.gemini/commands
2. Create a `tech-edit.toml` file that includes the prompt with rules to validate your article against.
touch ~/.gemini/commands/tech-edit.toml
3. Copy the content from `tech-edit.toml` file. This includes the rules that we abstracted using the AI function in a `.toml` complaint format, along with other instructions.
4. Save the `.toml` file.
In the Gemini CLI interactive window, type `/tech-edit`, you should see the following:
To test the editorial capacity of our custom command, we will create a badly formatted and poorly formatted file, `poor-sample.md` (thank you again, Gemini), and run it through the custom command.
- In your terminal, navigate to a directory where you want to store the sample file.
- Run the following command to create an poor-sample.md file.
touch poor-sample.md
3. Run the following command to open the file:
nano poor-sample.md
4. Copy and paste the content of the file with the content from the file here.
5. Save the file.
6. Run the following command to start the Gemini CLI:
gemini
7. In the interactive window of the Gemini CLI, type `/tech-edit poor-sample.md`, and press Enter.
The following show how the tool validates, suggests edits, and also the well formatted output.
The final revised version of the file in markdown format is as follows:
Source Credit: https://medium.com/google-cloud/editing-with-ai-how-i-coded-the-google-style-guide-into-a-gemini-custom-commands-workflow-06086eed75a2?source=rss—-e52cf94d98af—4