This PR introduces utility scripts designed to resolve agent context window overloading. (#319)

* Implemented scripts and a Python utility to optimize agent skills, preventing context window overload, and document their usage.

* feat(infra): add skills optimization scripts with bundle support and fixed archive logic

* Removed Linux / Mac optimize-skills

* Removed the Linux Section

* feat(infra): final robust skill optimization suite with Library Mode

* Removed

* Updated the read me changed the optimisation to activation-skills

* Updated ReadMe

* docs: trim activation script README diff

---------

Co-authored-by: sck_0 <samujackson1337@gmail.com>
This commit is contained in:
Maeve Fernandes
2026-03-16 20:26:42 +05:30
committed by GitHub
parent bae5fccf88
commit de21ffa2c6
3 changed files with 166 additions and 0 deletions

View File

@@ -344,6 +344,17 @@ That guide includes:
- the storage folders that usually need to be cleared
- an optional batch helper adapted from [issue #274](https://github.com/sickn33/antigravity-awesome-skills/issues/274)
### Fixing agent overload (activation scripts)
If your agent is struggling with context window limits due to too many loaded skills, use the activation script. It keeps the full library in a separate archive folder and only activates the bundles or skills you need into the live Antigravity skills directory.
Windows example from the repository root:
```bat
.\scripts\activate-skills.bat "Web Wizard" "Integration & APIs"
.\scripts\activate-skills.bat --clear
```
## Web App
The web app is the fastest way to navigate a large repository like this.

109
scripts/activate-skills.bat Normal file
View File

@@ -0,0 +1,109 @@
@echo off
setlocal EnableDelayedExpansion
:: --- CONFIGURATION ---
set "BASE_DIR=%USERPROFILE%\.gemini\antigravity"
set "SKILLS_DIR=%BASE_DIR%\skills"
set "LIBRARY_DIR=%BASE_DIR%\skills_library"
set "ARCHIVE_DIR=%BASE_DIR%\skills_archive"
set "REPO_SKILLS=%~dp0..\skills"
echo Activating Antigravity skills...
:: --- ARGUMENT HANDLING ---
set "DO_CLEAR=0"
set "EXTRA_ARGS="
for %%a in (%*) do (
if /I "%%a"=="--clear" (
set "DO_CLEAR=1"
) else (
if "!EXTRA_ARGS!"=="" (set "EXTRA_ARGS=%%a") else (set "EXTRA_ARGS=!EXTRA_ARGS! %%a")
)
)
:: --- LIBRARY SYNC ---
:: If running from the repo, ensure the library is synced with the 1,200+ skills source.
if exist "%REPO_SKILLS%" (
echo Syncing library with repository source...
if not exist "%LIBRARY_DIR%" mkdir "%LIBRARY_DIR%" 2>nul
robocopy "%REPO_SKILLS%" "%LIBRARY_DIR%" /E /NFL /NDL /NJH /NJS /XO >nul 2>&1
)
:: If still no library, try to create one from current skills or archives.
if not exist "%LIBRARY_DIR%" (
echo Initializing skills library from local state...
mkdir "%LIBRARY_DIR%" 2>nul
:: 1. Migrate from current skills folder
if exist "%SKILLS_DIR%" (
echo + Moving current skills to library...
robocopy "%SKILLS_DIR%" "%LIBRARY_DIR%" /E /MOVE /NFL /NDL /NJH /NJS >nul 2>&1
)
:: 2. Merge from all archives
for /f "delims=" %%i in ('dir /b /ad "%BASE_DIR%\skills_archive*" 2^>nul') do (
echo + Merging skills from %%i...
robocopy "%BASE_DIR%\%%i" "%LIBRARY_DIR%" /E /NFL /NDL /NJH /NJS >nul 2>&1
)
)
:: --- PREPARE ACTIVE FOLDER ---
if "!DO_CLEAR!"=="1" (
echo [RESET] Archiving and clearing existing skills...
if exist "%SKILLS_DIR%" (
set "ts=%date:~10,4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%%time:~6,2%"
set "ts=!ts: =0!"
robocopy "%SKILLS_DIR%" "%ARCHIVE_DIR%_!ts!" /E /MOVE /NFL /NDL /NJH /NJH >nul 2>&1
)
) else (
echo [APPEND] Layering new skills onto existing folder...
)
mkdir "%SKILLS_DIR%" 2>nul
:: --- BUNDLE EXPANSION ---
set "ESSENTIALS="
echo Expanding bundles...
python --version >nul 2>&1
if not errorlevel 1 (
:: Safely pass all arguments to Python (filtering out --clear)
python "%~dp0..\tools\scripts\get-bundle-skills.py" !EXTRA_ARGS! > "%TEMP%\skills_list.txt" 2>nul
:: If no other arguments, expand Essentials
if "!EXTRA_ARGS!"=="" python "%~dp0..\tools\scripts\get-bundle-skills.py" Essentials > "%TEMP%\skills_list.txt" 2>nul
if exist "%TEMP%\skills_list.txt" (
set /p ESSENTIALS=<"%TEMP%\skills_list.txt"
del "%TEMP%\skills_list.txt"
)
)
:: Fallback if Python fails or returned empty
if "!ESSENTIALS!"=="" (
if "!EXTRA_ARGS!"=="" (
echo Using default essentials...
set "ESSENTIALS=api-security-best-practices auth-implementation-patterns backend-security-coder frontend-security-coder cc-skill-security-review pci-compliance frontend-design react-best-practices react-patterns nextjs-best-practices tailwind-patterns form-cro seo-audit ui-ux-pro-max 3d-web-experience canvas-design mobile-design scroll-experience senior-fullstack frontend-developer backend-dev-guidelines api-patterns database-design stripe-integration agent-evaluation langgraph mcp-builder prompt-engineering ai-agents-architect rag-engineer llm-app-patterns rag-implementation prompt-caching context-window-management langfuse"
) else (
:: Just use the literal arguments
set "ESSENTIALS=!EXTRA_ARGS!"
)
)
:: --- RESTORATION ---
echo Restoring selected skills...
for %%s in (!ESSENTIALS!) do (
if exist "%SKILLS_DIR%\%%s" (
echo . %%s ^(already active^)
) else if exist "%LIBRARY_DIR%\%%s" (
echo + %%s
robocopy "%LIBRARY_DIR%\%%s" "%SKILLS_DIR%\%%s" /E /NFL /NDL /NJH /NJS >nul 2>&1
) else (
echo - %%s ^(not found in library^)
)
)
echo.
echo Done! Antigravity skills are now activated.
pause

View File

@@ -0,0 +1,46 @@
#!/usr/bin/env python3
import sys
import re
from pathlib import Path
def get_bundle_skills(bundle_queries):
bundles_path = Path(__file__).parent.parent.parent / "docs" / "users" / "bundles.md"
if not bundles_path.exists():
print(f"Error: {bundles_path} not found", file=sys.stderr)
return []
content = bundles_path.read_text(encoding="utf-8")
# Split by bundle headers
sections = re.split(r'\n### ', content)
selected_skills = set()
for query in bundle_queries:
query = query.lower().strip('"\'')
found = False
for section in sections:
header_line = section.split('\n')[0].lower()
if query in header_line:
found = True
# Extract skill names from bullet points: - [`skill-name`](../../skills/skill-name/)
skills = re.findall(r'- \[`([^`]+)`\]', section)
selected_skills.update(skills)
if not found:
# If query not found in any header, check if it's a skill name itself
# (Just in case the user passed a skill name instead of a bundle)
selected_skills.add(query)
return sorted(list(selected_skills))
if __name__ == "__main__":
if len(sys.argv) < 2:
# Default to Essentials if no query
queries = ["essentials"]
else:
queries = sys.argv[1:]
skills = get_bundle_skills(queries)
if skills:
print(" ".join(skills))