Define a macro that eliminates this repetitive pattern:
(-> (from :users) (when include-inactive (where (:= :active 0))) (when sort-by-date (order-by :created_at)))

Issue: Macro call that should be transformed by ->

Macro definition:
(defmacro -> (value &rest forms)
  "Smart threading macro that dispatches based on clause types returned by forms.

   This macro enables immutable query composition by threading clauses through
   query-state objects. Creates a single copy at the beginning, then destructively
   adds clauses for efficiency. Supports both v1 select-statements and composer query-states.

   Forms that evaluate to NIL are skipped, enabling conditional composition:
     (-> (from :users)
         (when active-only (where (:= :active 1)))
         (when sort-by-name (order-by :name)))

   Examples:
     ;; With composer clause
     (-> (from :users)
         (where (:= :active 1))
         (order-by :name))

     ;; With v1 select-statement (backward compatible)
     (-> (select (:id :name) (from :users))
         (where (:= :active 1))
         (order-by :name))

     ;; Conditional composition
     (-> (from :users)
         (when include-inactive (where (:= :active 0)))
         (when sort-by-date (order-by :created_at)))"
  (a:with-gensyms (threaded-var clause-var)
    `(let* ((,threaded-var ,value)
            ;; Convert to query-state and copy once at the beginning
            (,threaded-var
              (typecase ,threaded-var
                (query-state-base (copy-query-state-immutable ,threaded-var))
                (stmt:select-statement (select-statement-to-query-state ,threaded-var))
                (stmt:insert-into-statement (insert-statement-to-query-state ,threaded-var))
                (stmt:update-statement (update-statement-to-query-state ,threaded-var))
                (stmt:delete-from-statement (delete-statement-to-query-state ,threaded-var))
                (otherwise (add-clause (make-select-query-state) ,threaded-var)))))
       ;; Now destructively add clauses (no more copying), skipping NILs
       ,@(loop for form in forms
               collect `(let ((,clause-var ,(if (listp form)
                                                ;; For list forms, call the function with its arguments (no threading)
                                                `(,(car form) ,@(cdr form))
                                                ;; For symbol forms, call the function with no arguments
                                                `(,form))))
                          (when ,clause-var
                            (add-clause ,threaded-var ,clause-var))))
       ,threaded-var)))

Macroexpansion:
(let* ((#:threaded-var147 (from :users)) (#:threaded-var147 (typecase #:threaded-var147 (query-state-base (copy-query-state-immutable #:threaded-var147)) (stmt:select-statement (select-statement-to-query-state #:threaded-var147)) (stmt:insert-into-statement (insert-statement-to-query-state #:threaded-var147)) (stmt:update-statement (update-statement-to-query-state #:threaded-var147)) (stmt:delete-from-statement (delete-statement-to-query-state #:threaded-var147)) (otherwise (add-clause (make-select-query-state) #:threaded-var147))))) (let ((#:clause-var148 (when include-inactive (where (:= :active 0))))) (when #:clause-var148 (add-clause #:threaded-var147 #:clause-var148))) (let ((#:clause-var148 (when sort-by-date (order-by :created_at)))) (when #:clause-var148 (add-clause #:threaded-var147 #:clause-var148))) #:threaded-var147)