AGENT SKILL

ams-less-pro

暂无简介

License 许可
MIT
所属仓库
TanNhatCMS/jarvis
最近更新
2026-11-07
Stars
★ 0
Forks
1

03 SKILL.md 正文

Less Pro

A practical guide to Less: variables, mixins (parametric + guarded), operations, namespaced imports, and build integration — primarily for maintaining Less-based codebases and theming component libraries built on Less.

Overview

Less is a CSS preprocessor in the Sass/Stylus family, notable for its JavaScript-based implementation and its role as the styling layer of major UI libraries (notably Ant Design, which themes via Less variables). New projects rarely choose Less today, but large existing codebases run on it — this skill is about working effectively in those codebases and customizing Less-based design systems.

When to use

  • Theming Ant Design or other Less-based component libraries (@primary-color overrides).
  • Maintaining existing Less stylesheets.
  • Build integration: less-loader, standalone lessc, or in-browser less.js (dev only).
  • Deciding whether to migrate Less → modern CSS/Sass.

Core concepts

  • Variables. @primary-color: #1890ff; — lazy-loaded (defined on last declaration wins, usable before definition). Referenced as @var in values and @{var} in selectors/URLs.
  • Mixins. .bordered() { border: 1px solid #ddd; } then .card { .bordered(); }. Parametric: .rounded(@radius: 4px) { border-radius: @radius; }. Namespaced: #bundle > .mixin().
  • Guards. Conditional mixins: .mixin(@a) when (@a > 10) { ... } — pattern matching by arity/guards, Less's version of control flow.
  • Operations & functions. width: @base * 2;, color: lighten(@primary-color, 10%);, fade(), mix(). Any numeric/color value can be computed.
  • Nesting & &. Standard nesting; & for parent reference (&:hover, &__element).
  • @import. (reference) imports without output (great for mixin libraries), (inline), (css) passthrough. Import once semantics per file.
  • Detached rulesets. @rules: { color: red; }; .x { @rules(); } — reusable declaration blocks, useful for theming APIs.

Practical workflow

1. Theme a Less-based library (Ant Design example).

// webpack less-loader options (or vite plugin-less)
{
  lessOptions: {
    modifyVars: {
      '@primary-color': '#7c3aed',
      '@border-radius-base': '8px',
      '@font-family': 'Inter, sans-serif',
    },
    javascriptEnabled: true,
  },
}

modifyVars overrides library defaults without forking — the sanctioned theming path.

2. Organize.

styles/
  variables.less   // your tokens (@import (reference) libraries' vars if needed)
  mixins.less      // parametric mixins, guarded variants
  base.less
  components/

One entry main.less importing the rest; (reference) for mixin-only imports to avoid duplicate output.

3. Parametric + guarded mixins.

.button-variant(@bg; @color: #fff) {
  background: @bg;
  color: @color;
  &:hover when (lightness(@bg) > 50%) { background: darken(@bg, 10%); }
  &:hover when (lightness(@bg) <= 50%) { background: lighten(@bg, 10%); }
}

4. Build. lessc src/main.less dist/main.css --source-map; watch with --watch or bundler loaders. Never ship less.js in-browser compilation to production (slow, FOUC).

Common pitfalls

  • Lazy variable gotcha. Last declaration wins everywhere, even above it — redefining @x in an imported file silently changes earlier usages. Namespace your variables.
  • javascriptEnabled security. Less's inline JS evaluation (`...`) is off by default for good reason — enabling it for modifyVars math is normal, but don't evaluate untrusted input.
  • In-browser less.js in prod. Dev convenience only. Compile at build time; shipping the compiler + FOUC is a performance and UX bug.
  • Import duplication. Multiple @import "mixins.less" without (reference) emits the file's output repeatedly. Mixin libraries should be (reference) imports or output-free.
  • Overriding library internals. Reaching past modifyVars into a library's private mixins breaks on upgrade. Stay on the public theming API.
  • Math precision. 0.1 + 0.2-style float artifacts in computed values; round where it matters (round(), ceil()).
  • Migrating away blindly. If the codebase themes Ant Design via Less, "rewrite in Tailwind" means reimplementing the theme layer. Cost it: often better to keep Less for the library theme and use modern CSS for app code.
  • No sourcemaps. Debugging compiled CSS without --source-map is miserable. Always generate them.

04 同仓库更多 Skills

TanNhatCMS
TanNhatCMS/jarvis

web-scrape

Turn web pages into LLM-ready markdown via the Firecrawl API (renders JS, anti-bot handling). Use when browser_open/fetch fails on JS-heavy pages, or when you need clean markdown/structured extraction from a site. Requires FIRECRAWL_API_KEY.

★ 0
TanNhatCMS
TanNhatCMS/jarvis

design-taste-frontend

tasteskill v2, the anti-slop frontend skill. Art direction for websites, distilled from a study of 247 curated gallery sites (One Page Love, Awwwards Sites of the Day). Deals researched directions (idea, composition, type, palette, photographs, section blueprints) from a library, enforces a strict no-slop house style with a real-browser inspector, and runs a look-and-fix loop on screenshots. Use this whenever you build, design, redesign, restyle, polish or review a landing page, marketing site, portfolio, product page, one-pager, hero or any public-facing web page, in any stack (HTML/CSS, React, Next.js, Vue, Svelte, Astro, Tailwind) — also when the user says a page looks generic, templated, "AI-made", sloppy, or asks to make it look designed, premium, award-level or less like every other site. Not for dashboards or app screens.

★ 0
TanNhatCMS
TanNhatCMS/jarvis

test-driven-development

Use when implementing any feature or bugfix, before writing implementation code

★ 0
TanNhatCMS
TanNhatCMS/jarvis

systematic-debugging

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes

★ 0
TanNhatCMS
TanNhatCMS/jarvis

requesting-code-review

Use when completing tasks, implementing major features, or before merging to verify work meets requirements

★ 0
TanNhatCMS
TanNhatCMS/jarvis

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).

★ 0