
Google Antigravity was announced last week as the next generation agentic IDE. I’m very impressed with it so far. It already helped me to upgrade my blog to the latest Hugo (that I’ve been putting off for a long time). It even recognized that some of the shortcodes (eg. Twitter) from the old version changed in the new version and automatically updated my blog posts with the new version of the shortcodes. Nice!
There are many blog posts on how great Antigravity is and also a codelab. Once you get over the hype of Antigravity, you’d want to customize it to make sure it behaves exactly as you want. That’s the topic of this blog post.
Rules and Workflows
Antigravity comes with a couple of customization options that you might not be aware of. If you click on the ... on
the top right corner and choose Customizations, you will see Rules and Workflows as two customization options:

Rules help guide the behavior of the agent. These are guidelines you can provide to make sure the agent follows as
it generates code, tests, etc. For example, you might want the agent to follow a certain code style, or to always
document methods. You can add these as rules and the agent will take them into account.
Workflows are saved prompts that you can trigger on demand with /, as you interact with the agent. They are similar
to Rules in the sense that they also guide the behavior of the agent but they’re triggered by the user on demand.
Maybe a good analogy is that Rules are more like system instructions whereas Workflows are more like saved prompts
that you can choose on demand.
Both Rules and Workflows can be applied globally or per workspace and saved to the following locations:
- Global rule:
~/.gemini/GEMINI.md - Global workflow:
~/.gemini/antigravity/global_workflows/global-workflow.md - Workspace rules:
your-workspace/.agent/rules/ - Workspace workflows:
your-workspace/.agent/workflows/
Let’s look at a concrete example now.
Without rules and workflows
Let’s say we want to implement some basic search and sort algorithms with Antigravity.
First, let’s try to do this without any rules and workflows and see what we get.
We can start with an empty main.py file:
def main():
pass
if __name__ == "__main__":
main()
Then, ask Antigravity: Implement binary search and bubble sort.
You’ll probably get something similar to this:
def binary_search(arr, target):
left, right = 0, len(arr) - 1
while left <= right:
mid = left + (right - left) // 2 # Avoid potential overflow
if arr[mid] == target:
return mid
elif arr[mid] < target:
left = mid + 1
else:
right = mid - 1
return -1
def bubble_sort(arr):
n = len(arr)
for i in range(n):
# Flag to optimize for already sorted arrays
swapped = False
# Last i elements are already in place
for j in range(0, n - i - 1):
if arr[j] > arr[j + 1]:
arr[j], arr[j + 1] = arr[j + 1], arr[j]
swapped = True
# If no swaps occurred, array is sorted
if not swapped:
break
return arr
def main():
print("=" * 50)
print("BINARY SEARCH DEMONSTRATION")
print("=" * 50)
# Binary Search Examples
sorted_arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]
print(f"\nSorted array: {sorted_arr}")
test_values = [7, 15, 1, 19, 10, 20]
print("\nIterative Binary Search:")
for val in test_values:
result = binary_search(sorted_arr, val)
if result != -1:
print(f" Found {val} at index {result}")
else:
print(f" {val} not found in array")
print("\n" + "=" * 50)
print("BUBBLE SORT DEMONSTRATION")
print("=" * 50)
# Bubble Sort Examples
unsorted_arr1 = [64, 34, 25, 12, 22, 11, 90]
print(f"\nOriginal array: {unsorted_arr1}")
bubble_sort(unsorted_arr1)
print(f"Sorted array: {unsorted_arr1}")
if __name__ == "__main__":
main()
When you run it, it works:
python main.py
==================================================
BINARY SEARCH DEMONSTRATION
==================================================
Sorted array: [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]
Iterative Binary Search:
Found 7 at index 3
Found 15 at index 7
Found 1 at index 0
Found 19 at index 9
10 not found in array
20 not found in array
==================================================
BUBBLE SORT DEMONSTRATION
==================================================
Original array: [64, 34, 25, 12, 22, 11, 90]
Sorted array: [11, 12, 22, 25, 34, 64, 90]
It’s impressive that we got working code and some examples how to run it in a second! But the code is not documented,
everything is put into a single main.py, there are no unit tests, etc.
Let’s see if we can put some rules and workflows in place to make this better.
Add rules
Let’s add a couple of rules. As I mentioned before, rules and workflows can be global or per workspace. In this case, let’s just add them for the workspace.
First, let’s add the following code-style-guide.md rule for basic code style and comments:
* Make sure all the code is styled with PEP 8 style guide
* Make sure all the code is properly commented
Second, let’s add another rule to make sure the code is generated in a more modular way with examples in code-generation-guide.md:
* The main method in main.py is the entry point to showcase functionality.
* Do not generate code in the main method. Instead generate distinct functionality in a new file (eg. feature_x.py)
* Then, generate example code to show the new functionality in a new method in main.py (eg. example_feature_x) and simply call that method from the main method.
The two rules are saved and ready:

Add a workflow
Next, let’s define a workflow to generate unit tests. I chose to define this as a workflow, because I want to have the option of triggering unit tests once I’m happy with the code (rather than the agent generating unit tests all the time)
This is the definition of a generate-unit-tests.md workflow:
* Generate unit tests for each file and each method
* Make sure the unit tests are named similar to files but with test_ prefix
My workflow is also ready to go now:

With rules and workflows
Now, we’re ready to generate code again with Antigravity. I removed all the previously generated code and ask the same
question to Antigravity: Implement binary search and bubble sort.
After a minute or two, I get three files in my workspace: main.py, bubble_sort.py, binary_search.py and it’s great
to see that all my rules are implemented.
For example, the binary_search.py is nicely documented and in good style:
"""
Binary Search Algorithm Implementation
This module provides an implementation of the binary search algorithm,
which efficiently searches for a target value in a sorted list.
Time Complexity: O(log n)
Space Complexity: O(1)
"""
def binary_search(arr, target):
"""
Perform binary search on a sorted array to find the target value.
Args:
arr (list): A sorted list of comparable elements
target: The value to search for in the array
Returns:
int: The index of the target if found, -1 otherwise
Example:
>>> binary_search([1, 3, 5, 7, 9], 5)
2
>>> binary_search([1, 3, 5, 7, 9], 6)
-1
"""
left = 0
right = len(arr) - 1
while left <= right:
# Calculate middle index (avoiding potential overflow)
mid = left + (right - left) // 2
# Check if target is at mid
if arr[mid] == target:
return mid
# If target is greater, ignore left half
elif arr[mid] < target:
left = mid + 1
# If target is smaller, ignore right half
else:
right = mid - 1
# Target not found
return -1
Main method in main.py is nice and clean:
def main():
"""
Main entry point to showcase binary search and bubble sort functionality.
"""
example_binary_search()
example_bubble_sort()
print("\n" + "=" * 50)
if __name__ == "__main__":
main()
It also has the example methods I asked for:
def example_bubble_sort():
"""
Demonstrate bubble sort algorithm with various test cases.
"""
print("\n" + "=" * 50)
print("Bubble Sort Examples")
print("=" * 50)
# Example 1: Basic sorting - unsorted array
arr1 = [64, 34, 25, 12, 22, 11, 90]
print(f"\nOriginal array: {arr1}")
sorted_arr1 = bubble_sort(arr1.copy())
print(f"Sorted (ascending): {sorted_arr1}")
Great! The last piece is the unit tests. Now that I’m happy with the code, let’s see if I can trigger the generate unit test workflow.
I go to the chat and start typing /generate and Antigravity already knows about my workflow:

I select and hit enter. After a few seconds, I get new files in my workspace: test_binary_search.py, test_bubble_sort.py:

And a number of tests implemented for me in test_bubble_sort.py:
"""
Unit tests for bubble_sort module.
This module contains comprehensive unit tests for both ascending and
descending bubble sort implementations.
"""
import unittest
from bubble_sort import bubble_sort, bubble_sort_descending
class TestBubbleSort(unittest.TestCase):
"""Test cases for the bubble_sort function (ascending order)."""
def test_unsorted_array(self):
"""Test sorting a basic unsorted array."""
arr = [64, 34, 25, 12, 22, 11, 90]
expected = [11, 12, 22, 25, 34, 64, 90]
result = bubble_sort(arr.copy())
self.assertEqual(result, expected)
def test_already_sorted(self):
"""Test sorting an already sorted array (best case)."""
arr = [1, 2, 3, 4, 5, 6, 7]
expected = [1, 2, 3, 4, 5, 6, 7]
result = bubble_sort(arr.copy())
self.assertEqual(result, expected)
...
It’s actually 61 tests total, way more than I’d have written myself!
pytest
=============================================================== test session starts ================================================================
platform darwin -- Python 3.13.0, pytest-7.4.3, pluggy-1.6.0
rootdir: /Users/atamel/dev/local/testing/antigravity/rules-workflows
plugins: anyio-4.10.0
collected 61 items
test_binary_search.py ............................... [ 50%]
test_bubble_sort.py .............................. [100%]
================================================================ 61 passed in 0.03s ================================================================
Conclusion
In this blog post, I showed you how to customize Antigravity with rules and workflows. I’m super impressed with Antigravity, and I’ll show you more tips and tricks in a future blog post. Here are some links to learn more: