Define a macro that eliminates this repetitive pattern:
(-> (select (:id :name) (from :users)) (where (:= :active 1)) (order-by :name))

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-var145 (select (:id :name) (from :users))) (#:threaded-var145 (typecase #:threaded-var145 (query-state-base (copy-query-state-immutable #:threaded-var145)) (stmt:select-statement (select-statement-to-query-state #:threaded-var145)) (stmt:insert-into-statement (insert-statement-to-query-state #:threaded-var145)) (stmt:update-statement (update-statement-to-query-state #:threaded-var145)) (stmt:delete-from-statement (delete-statement-to-query-state #:threaded-var145)) (otherwise (add-clause (make-select-query-state) #:threaded-var145))))) (let ((#:clause-var146 (where (:= :active 1)))) (when #:clause-var146 (add-clause #:threaded-var145 #:clause-var146))) (let ((#:clause-var146 (order-by :name))) (when #:clause-var146 (add-clause #:threaded-var145 #:clause-var146))) #:threaded-var145)