Skills

What is a 'Skill'?

  • A 'skill' is an object that wrappers a tool such as Webpack, ESLint, Babel, and others
  • It decides how the tool's configuration is changed so it can work with other tools
  • Skills can be run by a subcommand they specify. For example, the @alfred/skill-webpack skill is run with the build subcommand it registers
  • Alfred has default skills that can be overriden

Adding Skills

To use a skill in your project, use the alfred learn <skill-pkg-name> command, where skill-pkg-name is the package name of the skill you want to install.

Here are a few examples of learning a skill:

# Installing a skill
alfred learn @alfred/skill-lodash
# Installing multiple skills
alfred learn @alfred/skill-react @alfred/skill-redux

Skills with Subcommands

Alfred comes with default skills. Below is a table of how these skills and which subcommands and targets they support.

Default SkillsSubcommandsTargets
@alfred/skill-parcelstart, buildapp
@alfred/skill-rollupbuildlib
@alfred/skill-eslintlintlib
@alfred/skill-prettierformatapp, lib
@alfred/skill-testtestapp, lib

Learning a skill can either replace or add subcommands to a project. For example, if you want to use webpack instead of parcel, you can run alfred learn @alfred/skill-webpack. Since both webpack and parcel support the build and start subcommands and parcel is a default skill, webpack will override parcel. Future calls to alfred run build and alfred run start will now use webpack instead of parcel.

Using Skills

Extending Skill Configs

// package.json
{
// ...
"alfred": {
"skills": [
["@alfred/skill-eslint", {
"extends": "airbnb",
"rules": {
"no-console": "off"
}
}]
]
}
}

Passing Command Line Flags to Skills

The following example passes flags to eslint. The example adds a custom formatter to eslint.

alfred run lint --format pretty