> For the complete documentation index, see [llms.txt](https://no0dles.gitbook.io/hammerkit/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://no0dles.gitbook.io/hammerkit/task/extending.md).

# Extending

Extending tasks can save a lot of duplicated tasks in bigger projects and monorepos. With the task `extend` property a base configuration can be used as a template.

The following sections and examples use the two predefined tasks in the `build.tsc.yaml` file — one of the ready-made templates shipped under [`best-practices/`](/hammerkit/recipes.md). Copy it into your project (or include it directly) to follow along.

{% code title="build.tsc.yaml" %}

```yaml
tasks:
  install:
    src:
      - package.json
      - package-lock.json
    generates:
      - node_modules
    cmds:
      - npm ci
      
  build:
    deps: [ install ]
    src:
      - tsconfig.json
      - src
    cmds:
      - node_modules/.bin/tsc
    generates:
      - dist
```

{% endcode %}

### Extend a task

Extending the `tsc:build` task will use all defined properties as a base. If nothing else is defined, it will be an exact copy with the working directory of the current build file.

{% code title=".hammerkit.yaml" %}

```yaml
tasks:
  build:
    extend: tsc:build
    
includes:
  tsc: ./build.tsc.yaml
```

{% endcode %}

### Override properties in an extend

Every extended task can override defined or undefined properties. In this example the dependency gets cleared and runs without a dependency to the `install` task.

{% code title=".hammerkit.yaml" %}

```yaml
tasks:
  build:
    extend: tsc:build
    deps: []
    
includes:
  tsc: ./build.tsc.yaml
```

{% endcode %}

### Naming the base task

`extend` uses the same `<prefix>:<task>` addressing as [dependencies](/hammerkit/task/dependencies.md): the part before the colon is the [include](/hammerkit/build-file/includes.md) (or [reference](/hammerkit/build-file/references.md)) prefix, and the part after it is the task name in that file. `extend: tsc:build` means "the `build` task from the file included as `tsc`". To extend a task in the *same* file, use its bare name (`extend: build-base`).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://no0dles.gitbook.io/hammerkit/task/extending.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
