| name | anitrend-agentic-workflow |
| description | Use when working autonomously in the AniTrend website repository and needing project-specific conventions, CI requirements, tool choices, or implementation patterns before making changes. |
AniTrend Agentic Workflow Skill
This skill turns the repository's agent guidance into concrete execution steps. Use it to stay aligned with AniTrend conventions while working with minimal supervision.
Objective
- Enable autonomous agents to complete development tasks without human intervention
- Ensure all work respects project conventions, CI/CD pipelines, and type safety
- Minimize context switching by providing clear, step-by-step workflows
- Maintain consistency across feature implementation, bug fixes, and infrastructure changes
When to Use This Skill
Use this skill when:
- Starting a new feature, bug fix, or refactoring task
- Integrating with external APIs (Jikan, Genkit, GitHub, Firebase)
- Adding or modifying AI flows in
src/ai/flows/
- Preparing for deployment or release
- Unsure about project conventions or workflows
- Validating work against CI/CD requirements
Tool Selection & Patterns
For Context Discovery
Prefer local inspection first, then GitHub CLI:
| Task | Tool | Why |
|---|
| Verify branch naming format | git branch -a + local .github/branch-lint.sh | Already in checkout |
| Check recent commits | git log --oneline -20 | Fast, local, confirms pattern |
| Validate package.json scripts | cat package.json + read_file | No need for remote call |
| Inspect workflow files | read_file on .github/workflows/*.yml | Authoritative, local reference |
| Check for CI failures | GitHub UI or gh run list | Real-time status, no local equivalent |
Prefer GitHub CLI for:
- Current PR status and review comments
- Checking branch protection rules
- Triggering manual workflow dispatch
- Validating remote branch state
For Browser-Based Validation
Use open_browser_page + screenshot_page when:
- Verifying UI changes visually (dev server at
http://localhost:9002)
- Testing responsive design across breakpoints
- Confirming Genkit AI flow output
- Validating analytics tracking (Firebase events)
- Reviewing metadata rendering (Open Graph tags)
Example workflow:
yarn dev
Workflow: Standard Feature Implementation
Follow this sequence for implementing any feature:
1. Branch Setup (git convention)
git fetch origin
git checkout -b feat/your-feature-name
Validation: The .github/branch-lint.sh pre-commit hook enforces format automatically.
2. Development & Type Safety
- Write TypeScript with strict mode (no
any, no unsafe casts)
- Use Zod schemas for external API responses
- Follow shadcn/ui patterns for new UI components
- Store configuration in
.env.local, never hardcode
Key files to reference:
src/lib/types.ts — Shared interfaces (Anime, RepoInfo, etc.)
src/lib/utils.ts — cn() utility for conditional Tailwind classes
tsconfig.json — TypeScript strict settings
.env.example — Required environment variables
3. Local Validation (pre-push gate)
yarn lint
yarn typecheck
yarn build
yarn test:e2e
Stop here if any step fails — fix issues before push.
4. Commit with Conventional Format
git add .
git commit -m "feat: add anime filter to discover page"
5. Push & Open PR
git push origin feat/your-feature-name
PR requirements:
- Title: Clear, descriptive summary
- Description: What problem does this solve?
- Checklist: Tests added, docs updated (if needed), breaking changes noted
6. Wait for CI (automated)
GitHub Actions runs:
- ci.yml: Lint → TypeScript → Build (on every push to main)
- Automated checks: Branch protection prevents merge if CI fails
If CI fails:
git add .
git commit -m "fix: resolve linting error in anime-card component"
git push origin feat/your-feature-name
7. Merge (human approval + CI pass)
Once CI passes and human review approves, merge via GitHub UI.
Workflow: Adding an AI Flow
AI flows live in src/ai/flows/ and use the server-side pattern.
1. Create flow file with Zod schema
'use server';
import { ai } from '@/ai/genkit';
import { z } from 'zod';
const InputSchema = z.object({
animeGenres: z.array(z.string()),
userPreferences: z.string(),
});
const OutputSchema = z.object({
recommendedAnimeIds: z.array(z.string()),
reasoning: z.string(),
});
type Input = z.infer<typeof InputSchema>;
type Output = z.infer<typeof OutputSchema>;
const prompt = ai.definePrompt({
name: 'myRecommendationPrompt',
input: { schema: InputSchema },
output: { schema: OutputSchema },
prompt: `Recommend anime that matches the user's preferences.`,
});
const recommendationFlow = ai.defineFlow(
{
name: 'myRecommendationFlow',
inputSchema: InputSchema,
outputSchema: OutputSchema,
},
async (input) => {
const { output } = await prompt(input);
if (!output) {
throw new Error('Failed to generate recommendation');
}
return output;
}
);
export async function getRecommendation(input: Input): Promise<Output | null> {
try {
return await recommendationFlow(input);
} catch (error) {
console.error('Flow failed:', error);
return null;
}
}
2. Register in dev.ts
import '@/ai/flows/my-recommendation-flow';
This makes the flow discoverable in Genkit dev server.
3. Test locally
yarn genkit:dev
4. Integrate UI component
'use client'
import { getRecommendation } from '@/ai/flows/my-recommendation-flow'
export function RecommendationUI() {
const [result, setResult] = useState<Output | null>(null)
const handleRecommend = async () => {
const output = await getRecommendation(input)
setResult(output)
}
return (
)
}
5. Validate & PR
Follow standard feature workflow (lint → typecheck → build → test → commit → push).
Workflow: Integrating External APIs
Reference implementation pattern from src/lib/:
For Jikan API (Anime Data)
const BASE_URL = 'https://api.jikan.moe/v4/';
export async function getTopAnime(page = 1): Promise<Anime[]> {
try {
const res = await fetch(`${BASE_URL}top/anime?page=${page}&limit=25`);
if (!res.ok) throw new Error(`API error: ${res.status}`);
const data = await res.json();
return data.data.map((anime) => ({
id: anime.mal_id.toString(),
title: anime.title_english || anime.title,
posterUrl: anime.images?.jpg?.image_url,
rating: anime.score,
}));
} catch (error) {
console.error('Jikan API failed:', error);
return [];
}
}
Key pattern:
- Always wrap in try-catch
- Return sensible default on error (empty array, null, etc.)
- Never expose raw API response to UI
- Transform to internal
types.ts schema
- Add rate-limit delays for batch requests
For Genkit (AI Model)
Already covered in "Adding an AI Flow" workflow above.
For GitHub API
const BASE_URL = 'https://api.github.com';
export async function getOrgRepos(org: string) {
try {
const res = await fetch(`${BASE_URL}/orgs/${org}/repos`, {
headers: {
Accept: 'application/vnd.github.v3+json',
},
});
if (res.status === 403) {
console.warn(`GitHub API rate limit exceeded`);
return [];
}
if (!res.ok) throw new Error(`API error: ${res.status}`);
const data = await res.json();
} catch (error) {
console.error('GitHub API failed:', error);
return [];
}
}
Workflow: Preparing a Release
Releases are automated by tags — your job is to prepare and trigger.
1. Update version in package.json
{
"version": "1.2.3"
}
2. Document changes
Create or update release notes, and update CHANGELOG.md only if the repository is maintaining one, noting:
- Breaking Changes (if any)
- New Features
- Bug Fixes
3. Create release branch & commit
git checkout -b release/v1.2.3
git add package.json
git commit -m "chore: prepare release v1.2.3"
git push origin release/v1.2.3
4. Open PR, get approval, merge to main
Once merged, trigger the next step.
5. Tag & push (triggers deploy.yml)
git tag v1.2.3
git push origin v1.2.3
Automation kicks in:
deploy.yml validates release
- Builds Docker image:
ghcr.io/anitrend/website:v1.2.3
- Triggers SSH remote deploy
- Creates GitHub Release page
6. Verify deployment
Check GitHub Release page for status, monitor container registry for image push.
Workflow: Debugging Failed CI
When GitHub Actions CI fails:
1. Inspect CI logs
- Go to PR → "Checks" tab
- Click failing job (e.g., "Lint & Type Check")
- Review error output
2. Reproduce locally
yarn install --immutable
yarn lint
yarn typecheck
yarn build
3. Fix the issue
Common failures:
- ESLint error:
yarn lint --fix to auto-fix
- TypeScript error: Fix type annotation or add explicit type
- Build error: Check for runtime errors, missing imports, or outdated dependencies
4. Commit & push
git add .
git commit -m "fix: resolve build error in animation component"
git push origin feat/your-feature
CI re-runs automatically.
Key Constraints & Guardrails
✅ MUST DO
- Use Yarn (not npm or pnpm) — immutable lockfile enforced
- Run full validation locally before push:
yarn lint && yarn typecheck && yarn build && yarn test:e2e
- Write strict TypeScript — no
any, no unsafe casts without justification
- Use Zod for external API schema validation
- Handle API errors gracefully — always provide fallbacks
- Follow branch naming:
<type>/<kebab-case>
- Use conventional commits:
type(scope): message
- Update
context.instructions.md if making architectural changes (per update-context.instructions.md)
- Environment variables: Use
.env.local locally, GitHub Secrets for CI/CD
❌ MUST NOT DO
- Commit secrets or hardcoded keys (use
.env.example as reference)
- Skip ESLint or TypeScript checks
- Modify Docker base images without approval
- Change Node version (pinned at 22)
- Merge PRs without passing CI (GitHub branch protection enforces this)
- Use
any type in TypeScript
- Add dependencies without testing full build
Environment Variables
Local Development (.env.local — git-ignored)
# Google Genkit AI
GOOGLE_GENKIT_API_KEY=<your-api-key>
# Firebase (optional, for analytics)
NEXT_PUBLIC_FIREBASE_PROJECT_ID=<project-id>
NEXT_PUBLIC_FIREBASE_API_KEY=<key>
# ... other Firebase config
# Reference: See .env.example for all available vars
CI/CD (GitHub Secrets)
Set up in GitHub repository settings → Secrets and variables → Actions:
GOOGLE_GENKIT_API_KEY — Genkit API key
DOCKER_REGISTRY_TOKEN — For GHCR push
- SSH keys for remote deploy
Quick Reference
Common Commands
yarn dev
yarn genkit:dev
yarn genkit:watch
yarn lint
yarn typecheck
yarn build
yarn test:e2e
git checkout -b feat/name
git commit -m "feat: ..."
git push origin feat/name
git tag v1.2.3
git push origin v1.2.3
File Locations
| Purpose | Path |
|---|
| Agentic workflows guide | .github/instructions/AGENTS.md |
| Architecture reference | .github/instructions/context.instructions.md |
| Git validation script | .github/branch-lint.sh |
| CI/CD workflows | .github/workflows/ |
| AI flows | src/ai/flows/ |
| API clients | src/lib/ |
| Type definitions | src/lib/types.ts |
| Shared utilities | src/lib/utils.ts |
Troubleshooting
| Issue | Solution |
|---|
| Port 9002 already in use | lsof -i :9002 then kill -9 PID |
| Yarn lock conflicts | yarn install --immutable (respect frozen lock) |
| TypeScript strict errors | Check tsconfig.json, use explicit types instead of any |
| ESLint failures | yarn lint --fix to auto-fix |
| Build cache stale | rm -rf .next && yarn build |
| Genkit API errors | Verify GOOGLE_GENKIT_API_KEY in .env.local |
Integration with AGENTS.md
This skill is the executable guide for AGENTS.md. Whenever you reference AGENTS.md for:
- Branch/commit conventions
- CI/CD workflows
- Architecture patterns
- API integration
- Testing & validation
...this skill provides the step-by-step workflow to implement it.
References
Skill Version: 1.0
Last Updated: April 2026
Alignment: AGENTS.md + context.instructions.md
For questions about this skill or AniTrend project conventions, consult the referenced guides or open an issue in the repository.