Imported from juanjaragavi/topfinanzas-mx-next (
.agents/skills/topfinanzas-mx-codebase/SKILL.md). Install upstream withnpx skills add juanjaragavi/topfinanzas-mx-next --skill topfinanzas-mx-codebase. Copyright stays with the author.
TopFinanzas MX Codebase
Use this skill as the implementation map for /Users/macbookpro/GitHub/topfinanzas-mx-next.
This is the Mexico property in the TopNetworks portfolio:
- Domain:
https://topfinanzas.com/mx - Market: Mexico
- Language:
es-MX - Currency context:
MXN - Framework: Next.js App Router, React 19, TypeScript, Tailwind
This skill is intentionally repository-specific. It complements (does not replace) the cross-repo orchestrator skill at:
/Users/macbookpro/GitHub/topfinanzas-mx-next/.agents/skills/topnetworks-sync-orchestrator/SKILL.md
Authoritative context to load first
Before major changes, read:
/Users/macbookpro/GitHub/topfinanzas-mx-next/TOPNETWORKS_COMPANY_PROFILE.md/Users/macbookpro/GitHub/TopNetworks-Inc.md/Users/macbookpro/GitHub/topfinanzas-mx-next/.agents/skills/topnetworks-sync-orchestrator/SKILL.md
When to use this skill
- Add or modify pages under
app/for MX routes. - Add/edit product content in
app/soluciones-financieras/**. - Update blog/category listings and post metadata.
- Change API endpoints in
app/api/**. - Modify analytics/ad behavior (
components/analytics/**,lib/ads/**). - Update SEO metadata, sitemaps, robots, or structured data.
- Prepare local validation and deployment-readiness checks.
Repository boundaries
- In-scope: MX codebase only (
topfinanzas-mx-next). - Out-of-scope unless explicitly requested: synchronized propagation to
topfinanzas-us-next,uk-topfinanzas-com,budgetbee-next. - Never push or deploy unless explicitly requested.
System map (implementation-relevant)
Runtime entry points
app/layout.tsx- Global metadata, GTM script injection, Google Ads/GAM components, UTM handlers, optional AdZep runtime, JSON-LD, global providers.
ENABLE_ADZEPflag currently gates AdZep script/bridge activation (currentlyfalse, so AdZep components are wired but inactive unless enabled).
app/page.tsx- Home entry, renders
HomeContent.
- Home entry, renders
next.config.mjsbasePath: "/mx"is a hard invariant.- Caching/security headers and route-level
X-Robots-Tagnoindex rules for funnels/testing/admin pages.
middleware.ts- Adds hreflang/canonical
Linkheaders. - Enforces recommender lock redirects for quiz-like routes.
- Adds hreflang/canonical
Application domains
- Content/listing routes:
app/blog/page.tsxapp/finanzas-personales/page.tsxapp/soluciones-financieras/page.tsxapp/tarjetas/page.tsxapp/prestamos/page.tsx
- Quiz/recommender/funnel routes:
app/campana-quiz/**,app/campana-quiz-short/**,app/quiz-2/**app/recomendador-de-tarjetas-de-credito-p1|p2|p3/**app/recomendador-de-prestamos-personales-p1/**app/enrutador/**,app/administrar-enrutador/**
Data/content sources
- Primary listing source:
lib/data/posts.ts(ALL_POSTS). - SEO route metadata source:
lib/seo-route-registry.ts. - Legal/static content:
content/legal/**. - Author attribution API source:
lib/data/authors.jsonviaapp/api/authors/route.ts.
Integrations and pipelines
- Google Sheets ingestion:
app/api/sheets/route.tsapp/api/sheets/short/route.ts- Uses Google service account env vars and upserts rows per email.
- Contact/newsletter:
app/api/contact/route.ts-> Brevo contacts + notes.app/api/subscribe/route.ts-> ActiveCampaign sync + ConvertKit subscribe.lib/kit/convertkit-client.ts.
- Search:
app/api/search/route.ts-> Vertex AI Search endpoint.
- Analytics and ad runtime:
components/analytics/google-ads.tsx,components/analytics/gam.tsx.- UTM:
utm-persister.tsx,utm-link-injector.tsx,utm-monitor.tsx. - AdZep stack:
components/analytics/adzep*.tsx,lib/ads/config.ts,lib/ads/activate-adzep.ts.
Local development and operations
Commands
- Install:
pnpm install - Dev:
pnpm dev(port3030) - Lint:
pnpm lint - Build:
pnpm build - Start:
pnpm start(port3030) - Format (mutating):
pnpm format
Deployment/readiness scripts
- Local workflow scripts in
scripts/:git-workflow.sh(interactive merge prompt; use only with explicit user request)sync-branches.shdeploy_update.sh(remote/server oriented)
- Orchestrator-aware predeploy wrapper:
scripts/topnetworks-predeploy.mjs- Delegates to orchestrator deploy-readiness CLI for this repo.
Environment and runtime contract
Observed env groups (by usage in API/runtime):
Required when the corresponding integration/feature is used:
- Google Sheets:
GOOGLE_SERVICE_ACCOUNT_EMAILGOOGLE_PRIVATE_KEYGOOGLE_SHEET_ID
- Brevo:
BREVO_API_KEY
- ActiveCampaign:
ACTIVECAMPAIGN_API_URLACTIVECAMPAIGN_API_KEY
- ConvertKit/Kit:
KIT_API_KEY- Optional
KIT_API_URL
- Search:
VERTEX_AI_SEARCH_API_KEY
Optional runtime controls:
- Logging toggle:
NEXT_PUBLIC_ENABLE_LOGGING
- Cookie validation/runtime flags (see env debug route):
NEXT_PUBLIC_COOKIE_VALIDATION_ENABLEDNEXT_PUBLIC_COOKIE_SHORT_EXPIRATION
Do not hardcode secrets. Do not edit .env* unless explicitly requested.
Invariants and guardrails
- Preserve
basePath: "/mx"behavior in routing and links. - Preserve MX canonical/hreflang behavior (
lib/seo.ts,middleware.ts). - Keep non-indexable funnel/test/admin routes blocked from crawl (
next.config.mjs,app/robots.ts). - Do not manually scatter ad activation calls; use approved AdZep bridge/utilities.
- Keep category pages dynamic from
ALL_POSTS(no hardcoded product lists inapp/tarjetas/page.tsxandapp/prestamos/page.tsx). - For blog/content changes, keep listing sources synchronized across all relevant listing views.
- For
app/soluciones-financieras/**, follow the strict layout standard in:.github/instructions/FINANCIAL_SOLUTIONS_LAYOUT_STANDARD.instructions.md
- Do not push to
HEADor deploy unless explicitly requested.
Common change recipes
1) Add a normal MX page
- Create route under
app/<slug>/page.tsx. - Add/adjust metadata (
generateMetadataor route metadata helper). - Ensure canonical path is under
/mxbehavior. - If page should not index, add noindex controls in
next.config.mjsand/or metadata. - Run
pnpm lintandpnpm build.
2) Add/edit a financial solution product
- Read
.github/instructions/FINANCIAL_SOLUTIONS_LAYOUT_STANDARD.instructions.md. - Create/update both pages (benefits + requirements pair) using the mandated structure.
- Update
lib/data/posts.tswith product entry (subCategory=creditCardsorloans). - Verify visibility on
/soluciones-financieras,/tarjetasor/prestamos. - If the route depends on registry-driven metadata, update
lib/seo-route-registry.ts. - Run
pnpm lintandpnpm build.
3) Add/edit blog or personal finance content
- Create/update article route under
app/finanzas-personales/**orapp/soluciones-financieras/**. - Update central list in
lib/data/posts.ts. - Ensure listing views reflect changes:
app/blog/page.tsxapp/finanzas-personales/page.tsxapp/soluciones-financieras/page.tsx- plus any additional listing arrays in use.
- If route metadata is registry-driven, update the SEO registry.
- Run lint/build and verify route rendering.
4) Add or modify API integration
- Implement in
app/api/<name>/route.ts. - Validate request fields and return clear status codes.
- Log through
apiLogger/scoped logger, not ad-hoc console logs. - Add/verify env vars required by the endpoint.
- Validate with local scripts or direct endpoint tests.
5) Modify analytics/ads behavior safely
- Start from
app/layout.tsxwiring and the relevant analytics components. - Keep GTM/Google Ads load order stable unless there is a specific requirement.
- For AdZep, modify
lib/ads/config.tsand bridge/utilities, not scattered page logic. - Respect excluded ad paths (quiz/funnel pages).
- Validate no overlay regressions and no blocked CTA interactions.
6) Prepare deployment readiness (without deploying)
- Run local quality gates:
pnpm lintandpnpm build. - Use orchestrator preflight wrapper:
node scripts/topnetworks-predeploy.mjs preflight --dry-runnode scripts/topnetworks-predeploy.mjs preflight --execute(only when explicitly requested)
- If preflight reports
AGENT_ACTION_REQUIRED, fix before any deployment action.
Orchestrator integration contract
This skill is the MX deep map. The orchestrator skill is the cross-repo coordinator.
Hand-off to orchestrator when
- A change must propagate to other TopNetworks repos.
- You need parity audits, multi-repo validation, or deployment planning across properties.
- Shared patterns (SEO/GEO/LLM indexing, analytics, ads, scripts, shared components) must stay aligned.
How to invoke orchestrator
- Skill hand-off prompt example:
@topnetworks-sync-orchestrator Propagate this approved MX pattern across US/UK/BudgetBee with localization preserved for domain, language, compliance, and route naming.
- CLI examples:
node .agents/skills/topnetworks-sync-orchestrator/scripts/topnetworks-sync.mjs statusnode .agents/skills/topnetworks-sync-orchestrator/scripts/topnetworks-sync.mjs parity
Shared expectations with orchestrator
- Classify changes as shared vs localized (MX language, compliance, route conventions).
- Preserve market-specific adaptation while syncing architecture patterns.
- Use orchestrator allowlisted validation and preflight commands before cross-repo deployment instructions.
- Keep local branch policy (
devworkflow) and do not leave repo parked onmainafter deployment prep.
Recommended paired workflow
- Use this skill to implement and validate MX changes.
- If propagation is needed, invoke
topnetworks-sync-orchestratorwith a propagation matrix. - Reconcile intentional differences explicitly (currency, regulatory text, locale voice, route names).
Completion checklist
- Architecture impact understood (route/module/integration touched).
- Listing and metadata synchronization completed where applicable.
- Noindex/canonical/basePath behavior preserved.
- Env contract unchanged or documented.
pnpm lintandpnpm buildcompleted for code changes.- Cross-repo implications either explicitly out-of-scope or handed to orchestrator.