Skip to main content

Squillify development is paused indefinitely. Read why, and discover what this experiment achieved. Read the story

MicroSkills Reference

Count Lines of Code

code.count_loc

ProductionBounded custom (Class B)Deterministicstrictfastv1.0.0
File inputNo network

Overview

When you supply source files, we count physical, blank, comment, code, and mixed lines per file using a lexical pass that respects string literals. Language is detected from the path extension unless you set it explicitly. We do not parse semantics, execute code, or walk a filesystem — do not use this for complexity metrics or AST analysis.

Naive line counters misclassify comments inside strings. We use the same lexical rules every time so your ratios stay trustworthy.

Reliability

STRICT and deterministic for identical inputs. Domain errors (not retryable; reduce input — unchanged retry will not succeed): LOC_FILE_LIMIT_EXCEEDED (more than 1,000 files — send fewer files); LOC_TOTAL_LIMIT_EXCEEDED (per-file or combined character limits exceeded — shrink file contents). Unsupported languages return in-band warnings, not failures.

Context footprint

Returns per-file rows, byLanguage aggregates, totals, and warnings. A successful call costs 1 execution credit.

When to use it

When you can supply file contents or file refs and need deterministic LOC breakdowns.

When you need semantic analysis, complexity, or filesystem discovery.

Scope

Note
Counts line-composition metrics per file for supported languages.

Non-goals

  • Does not parse or execute code
  • Does not compute complexity metrics
  • Does not walk a filesystem
  • Does not infer language from file content prose

Properties

IdempotentRetry safeStreaming supportedFile input supportedRequires external service

Capabilities

analysisparsing

Cost & billing

Flat rate per invocation

MetercallsBillable onsuccessCost per call1 credit

File handling

Accepts file_refProduces file_refMax input2 MBMax file size1.9 MB

File limits

Constraints this skill applies to your input and generated files. The “Limited by” column shows the static source of each cap; none of these can be raised by upgrading your plan.

LimitValueLimited by
Maximum size per input file1.9 MiBSkill and platform maximum

How we handle your data

Sensitive input, safe output
What this means

This skill may receive sensitive content, but it does not target sensitive data and returns only a structured non-sensitive result.

Squillify guarantees
  • Runs inside Squillify
  • This skill runs inside Squillify.
  • Payloads are not sent to an external service by this skill.
  • Squillify does not permanently store submitted payloads.
  • Telemetry records metadata only, not submitted content.
  • Submitted payloads are not used for training.
  • Submitted payloads are not reviewed by humans.
  • This skill does not target sensitive data.
  • The response does not contain submitted content.
Your responsibility

Squillify does not determine whether submitted content is sensitive. Your application is responsible for deciding what data it is allowed to submit. Your application is responsible for securing the response.

Read the Microskill Data Handling Policy

Input schema

FieldTypeRequiredDescription
filesarrayYesFrom 1 through 1,000 closed source-file specifications, each with path and exactly one content source.
optionsobjectNoReserved options object; omit it — currently unused unconstrained RFC 8259 JSON items.

Output schema

FieldTypeRequiredDescription
filesarrayYesFrom 0 through 1,000 retained file-count results in input order.
byLanguageobjectYesPurpose-bound map from supported language names to closed count objects.
totalsobjectYesClosed physical, blank, comment, code, and mixed line counts.
warningsarrayYesFrom 0 through 1,000 skipped-file warnings, each a closed code and safe message.

API contract

POST /v1/execute
curl
curl -sS -X POST "$BASE/v1/execute" -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{"skillKey":"code.count_loc","input":{"files":[{"path":"a.py","content":"# c\nx=1\n"}]}}'
Integrations
TypeScript SDK
import { Squillify } from "@squillify/sdk";

const sq = new Squillify({ apiKey: process.env.SQUILLIFY_API_KEY });

const { output } = await sq.execute("code.count_loc", {"files":[{"content":"// c\nclass A {}\n","path":"Main.java"}]});

Errors

CodeHTTPRetryableDescription
VALIDATION_ERROR400NoThe request payload failed schema validation.
UNAUTHORIZED401NoMissing or invalid API key.
SKILL_NOT_ACCESSIBLE403NoThe API key is not granted access to this skill.
SKILL_NOT_AVAILABLE_FOR_PLAN403NoThis skill is not included in your current plan.
PLAN_ELIGIBILITY_UNAVAILABLE503YesPlan eligibility could not be decided. Retry after backoff.
SKILL_NOT_FOUND404NoThe requested skill or version does not exist.
TENANT_RATE_LIMITED429YesRequest rate limit exceeded. Retry after backoff.
QUOTA_EXCEEDED429YesPlan quota exhausted. Retryable once the quota period resets.
EXECUTION_TIMEOUT504YesExecution exceeded the allowed time budget.
LOC_FILE_LIMIT_EXCEEDED429NoA size, quota, rate, or time limit was exceeded.
LOC_TOTAL_LIMIT_EXCEEDED429NoA size, quota, rate, or time limit was exceeded.

Other limits

LimitValue
Recommended inline bytes32 KiB

Limitations

  • Does not parse or execute code
  • Does not compute complexity metrics
  • Does not walk a filesystem
  • Does not infer language from file content prose
  • Cyclomatic complexity
  • Semantic or AST-based analysis

How to call

POST /v1/execute (requires authentication)

Request bodyjson
{
  "skillKey": "code.count_loc",
  "input": {
    "files": [
      {
        "content": "// c\nclass A {}\n",
        "path": "Main.java"
      }
    ]
  }
}

Examples

Single Java file with one comment line

Inputjson
{
  "files": [
    {
      "content": "// c\nclass A {}\n",
      "path": "Main.java"
    }
  ]
}
Expected outputjson
{
  "totals": {
    "physical": 2,
    "blank": 0,
    "comment": 1,
    "code": 1,
    "mixed": 0
  },
  "warnings": [],
  "byLanguage": {
    "java": {
      "physical": 2,
      "blank": 0,
      "comment": 1,
      "code": 1,
      "mixed": 0
    }
  },
  "files": [
    {
      "physical": 2,
      "blank": 0,
      "comment": 1,
      "code": 1,
      "mixed": 0,
      "path": "Main.java",
      "language": "java",
      "confidence": "extension",
      "supported": true,
      "bytes": 16
    }
  ]
}

Unknown extension returns a warning without counts

Inputjson
{
  "files": [
    {
      "content": "hello\n",
      "path": "notes.xyz"
    }
  ]
}
Expected outputjson
{
  "totals": {
    "physical": 0,
    "blank": 0,
    "comment": 0,
    "code": 0,
    "mixed": 0
  },
  "byLanguage": {},
  "files": [
    {
      "path": "notes.xyz",
      "supported": false,
      "language": "unknown",
      "bytes": 6
    }
  ],
  "warnings": [
    {
      "code": "LOC_LANGUAGE_UNSUPPORTED",
      "message": "Unsupported/unknown language for notes.xyz",
      "severity": "warning"
    }
  ]
}
  • Report code versus comment ratios in CI
  • Measure supplied source size by language
  • Aggregate LOC across a bounded file batch

Avoid for

  • Cyclomatic complexity
  • Semantic or AST-based analysis

Composable with

Safety & privacy

  • Runs without calling any external service.
  • Your payloads are never stored permanently.
  • Telemetry captures metadata only — never your payload contents.
  • We never train models on your payloads.
  • No human reviews your payloads.

Tags

codeanalysisloc