# Path set prefix strip

`path-set-prefix-strip` · version 1.0.0 · File paths (lexical) · free, no key needed

Strip a common directory prefix or base path from an array of paths lexically.

**Use when you need to: strip path prefix · remove base directory · relativize paths.**

## Supported

- strip path prefix
- remove base directory
- relativize paths

## Not supported

- stat file
- filesystem access

## Behavior

- For each path, check if it starts with the prefix (lexically normalized, directory-boundary aware). Strip the prefix from matching paths, returning the relative subpath. not_matched: count of paths that did not start with prefix. Windows: case-insensitive comparison of normalized segments.

## Input

- `paths` (array of string, required): min items 0; max items 10000; each min length 1; each max length 4096
- `prefix` (string, required): min length 1; max length 4096
- `format` (one of "posix", "windows", "auto", optional)
- `skip_non_matching` (boolean, optional)

## Output

- `stripped` (array of string, required)
- `not_matched` (integer, required)
- `format` (string, required)

## Limits

- max paths: 10000
- max path bytes: 4096

## Example

Request input:

```json
{
  "paths": [
    "/app/src/a.ts",
    "/app/src/b.ts",
    "/other/c.ts"
  ],
  "prefix": "/app/src"
}
```

Response:

```json
{
  "result": {
    "stripped": [
      "a.ts",
      "b.ts",
      "/other/c.ts"
    ],
    "not_matched": 1,
    "format": "posix"
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "path-set-prefix-strip",
  "version": "1.0.0",
  "input": {
    "paths": [
      "/app/src/a.ts",
      "/app/src/b.ts",
      "/other/c.ts"
    ],
    "prefix": "/app/src"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/path-set-prefix-strip/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"paths":["/app/src/a.ts","/app/src/b.ts","/other/c.ts"],"prefix":"/app/src"}'
```

The machine-readable contract is at [/v1/tools/path-set-prefix-strip/versions/1.0.0](/v1/tools/path-set-prefix-strip/versions/1.0.0).

### CLI

```sh
node cli.mjs run path-set-prefix-strip 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Path set dedupe](/tools/path-set-dedupe): Deduplicate an array of paths based on lexical equivalence while preserving first or last seen order.
- [Path set hierarchy tree](/tools/path-set-hierarchy-tree): Transform a flat array of file paths into a nested deterministic directory tree structure.
- [Path set partition directory](/tools/path-set-partition-directory): Partition an array of file paths into buckets grouped by parent directory or directory at a specified depth.
- [Path lexical common ancestor](/tools/path-lexical-common-ancestor): Compute the deepest common ancestor directory of a set of paths.
- [Path set classify](/tools/path-set-classify): Classify an array of file paths by file extension, depth histogram, and path format.
- [Path set difference](/tools/path-set-difference): Compute the set difference (A \ B) of two path collections using lexical path equivalence.
